|
-
Aug 21st, 2000, 02:32 AM
#1
Thread Starter
Member
Hi everyone !!
I'd like to know how i could get datas from a Text file where datas are separated with commas. My aim is to get these datas and make them appear in different Textboxes as a Data Object can do... I need to do SQL request too with this text file... How could I do ??
If someone could help...
Thank you
COSIDUS
-
Aug 21st, 2000, 04:43 AM
#2
Fanatic Member
Cosidus
Try this
Code:
Dim cnn As New ADODB.Connection
Dim rstText As New ADODB.Recordset
'Open the connection to the directory where the file is stored
cnn.Open "Provider=MSDASQL;Driver={Microsoft text Driver (*.txt; *.csv)};DBQ=C:\Test"
'Open the text file for import
rstText.Open "test.txt", cnn, adOpenKeyset
txtText1 = Trim(rstText.Fields(0))
txtText2 = Trim(rstText.Fields(1))
txtText3 = Trim(rstText.Fields(2))
'ETC
Hope this is of use to you
Gary Lowe 
VB6 (Enterprise) SP5
ADO 2.6
SQL Server 7 SP3
OK I know my spelling and grammer is crap so don't quote me on it!
To err is human to take the P! is only natural !!
Click on the top section of image for Marcus Miller website and bottom section of image for 'Run For Cover' sound clip

-
Aug 21st, 2000, 11:55 AM
#3
Guru
Or try this method, it doesn't use ODBC
Code:
'Uses ADO 2.1/5
Dim cn As ADODB.Connection
Dim rs As Recordset
Set cn = New Connection
Set rs = New Recordset
'open connection to folder that contains the CSV file
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\;Extended Properties=Text;"
'open the file
rs.Open "select * from test.csv", cn
'we have data
MsgBox rs.Fields(1).Value
-
Sep 11th, 2000, 03:23 PM
#4
Frenzied Member
In the example that Gary.Lowe gave, how would you specify a different delimiter, such as ::
It seems that your code only works if it's a comma..
Any help would be appreciated..
Dan
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|