I have a text file with two columns: Email and SSN
Below is the text file named login.txt:
Email, SSN
14342, 4323
43545, 2232
03232, 2322
23232, 0434
Below is the code for my file called sDSNFile.dsn
[ODBC]
DRIVER=Microsoft Text Driver (*.txt; *.csv)
UID=admin
UserCommitSync=Yes
Threads=3
SafeTransactions=0
PageTimeout=5
MaxScanRows=25
MaxBufferSize=2048
FIL=text
Extensions=None,asc,csv,tab,txt
DriverId=27
DefaultDir=C:\Inetpub\
Below is my code for displaying the text file:
<%
Dim sDSNFile
sDSNFile = "sDSNFile.dsn"
' Let's now dynamically retrieve the current directory
Dim sScriptDir
sScriptDir = Request.ServerVariables("SCRIPT_NAME")
sScriptDir = StrReverse(sScriptDir)
sScriptDir = Mid(sScriptDir, InStr(1, sScriptDir, "/"))
sScriptDir = StrReverse(sScriptDir)
' Time to construct our dynamic DSN
Dim sPath, sDSN
sPath = Server.MapPath(sScriptDir) & "\"
sDSN = "FileDSN=" & sPath & sDSNFile & _
";DefaultDir=" & sPath & _
";DBQ=" & sPath & ";"
' Building Data Connection
Dim Conn, rs
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open sDSN
' Get only the Name and Price fields
Dim sql
sql = "SELECT Email,SSN FROM login.txt"
'Implicitly create a recordset object with the
'results of this query
set rs = conn.execute(sql)
'Print out the contents of our recordset
Do WHile Not rs.EOF
Response.Write "Email: " & rs("Email")
Response.Write "<br>SSN: " & rs("SSN")
Response.Write "<HR>")
rs.MoveNext 'Move to the next record
Loop
'Close our recordset and connection
rs.close
set rs = nothing
conn.close
set conn = nothing
%>
My problem is that any of the numbers that begin with zero display with the zero missing. So if the number is 034332, it displays as 34332.
Below is the text file named login.txt:
Email, SSN
14342, 4323
43545, 2232
03232, 2322
23232, 0434
Below is the code for my file called sDSNFile.dsn
[ODBC]
DRIVER=Microsoft Text Driver (*.txt; *.csv)
UID=admin
UserCommitSync=Yes
Threads=3
SafeTransactions=0
PageTimeout=5
MaxScanRows=25
MaxBufferSize=2048
FIL=text
Extensions=None,asc,csv,tab,txt
DriverId=27
DefaultDir=C:\Inetpub\
Below is my code for displaying the text file:
<%
Dim sDSNFile
sDSNFile = "sDSNFile.dsn"
' Let's now dynamically retrieve the current directory
Dim sScriptDir
sScriptDir = Request.ServerVariables("SCRIPT_NAME")
sScriptDir = StrReverse(sScriptDir)
sScriptDir = Mid(sScriptDir, InStr(1, sScriptDir, "/"))
sScriptDir = StrReverse(sScriptDir)
' Time to construct our dynamic DSN
Dim sPath, sDSN
sPath = Server.MapPath(sScriptDir) & "\"
sDSN = "FileDSN=" & sPath & sDSNFile & _
";DefaultDir=" & sPath & _
";DBQ=" & sPath & ";"
' Building Data Connection
Dim Conn, rs
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open sDSN
' Get only the Name and Price fields
Dim sql
sql = "SELECT Email,SSN FROM login.txt"
'Implicitly create a recordset object with the
'results of this query
set rs = conn.execute(sql)
'Print out the contents of our recordset
Do WHile Not rs.EOF
Response.Write "Email: " & rs("Email")
Response.Write "<br>SSN: " & rs("SSN")
Response.Write "<HR>")
rs.MoveNext 'Move to the next record
Loop
'Close our recordset and connection
rs.close
set rs = nothing
conn.close
set conn = nothing
%>
My problem is that any of the numbers that begin with zero display with the zero missing. So if the number is 034332, it displays as 34332.