Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Connecting to text file

Status
Not open for further replies.

Waynest

Programmer
Jun 22, 2000
321
GB
Hi

I use the following connection string format to connect to my sql server databases

Public Const cnnstr As String = "Provider=sqloledb;Data Source=DEVSERVER;Initial Catalog=No3;uid=Waynest"

Is there a variant of this I can use to connect to a text file? Do I just need to specify a provider for text files, if so what is it called?

I ask because I want to trigger the transfer of the contents of a text file into a sql server table without using the bcp utility.
 
Hi Wayne,

I would normally use 'Open' to open the text file and then 'Line Input' to read each line.
Mike
michael.j.lacey@ntlworld.com
 
ODBC Driver for Text

oConn.Open "Driver={Microsoft Text Driver (*.txt; *.csv)};" & _
"Dbq=\somepath\;" & _
"Extensions=asc,csv,tab,txt;" & _
"Persist Security Info=False"

Note: Specify the filename in the SQL statement. For example:

oRs.Open "Select * From customer.csv", _
oConn, adOpenStatic, adLockReadOnly, adCmdText


Eric De Decker
vbg.be@vbgroup.nl

Licence And Copy Protection AxtiveX
Source CodeBook for the programmer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top