I'm Full of these today - Text File Connectio

Results 1 to 2 of 2

Thread: I'm Full of these today - Text File Connectio

  1. #1
    Join Date
    Dec 1969

    Default I'm Full of these today - Text File Connectio

    I&#039;ve been trying to connect to a Text File. I found this DSNLess connection string for it like the one for the database but when used I get the error<BR><BR><BR>Microsoft OLE DB Provider for ODBC Drivers error &#039;80004005&#039; <BR><BR>[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified <BR><BR>/textfiles.asp, line 76<BR><BR><BR><BR><BR>which is the string and the The string is<BR><BR>Set Conn = Server.CreateObject("ADODB.Connection")<BR>Conn.Op en "Driver={Microsoft Text Driver (*.txt;*.csv)};Dbq=f:Inetpubwww-cckbLogs;Extensions=asc,csv,tab,txt;Persist Security Info=False;"<BR>&#039;MS Text Driver DSNless connection

  2. #2
    Join Date
    Dec 1969

    Default Quick question

    Do you want to read a delimited text file (ex. comma, tab, etc) into a recordset OR simply read ENTIRE contents of a text file into a variable?<BR><BR>In the first case, you can use the Jet provider like this for a comma delimited file with the first record being the headers:<BR><BR>strConn = "Provider=Microsoft.Jet.OLEDB.4.0;data source="&server.mappath("/training/pc00099/validpcr/")&";Extended Properties=""text;HDR=YES;FMT=Delimited"""<BR><BR> You can even execute SQL against this for results.<BR><BR>In the second case, you can use the ADO stream object:<BR><BR>Set objStream = Server.CreateObject("ADODB.Stream")<BR>objStream.T ype = 2 <BR>objStream.Charset = "ascii"<BR>objStream.Open<BR>objStream.LoadFromFil e "yourpathyourtextfile.txt"<BR><BR>somestring = objStream.ReadText<BR><BR>objStream.Close<BR>Set objStream = nothing<BR><BR>Hope that helps<BR><BR>Pete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts