Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Database Access / February 2008



Tip: Looking for answers? Try searching our database.

about ADO vb and semi colon

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dave - 09 Feb 2008 07:40 GMT
hello,

Iuse ADO and I would like create automaticly a table in access with a text
file I use
semi-colon (;)

exemple
"value1";"value2";"value3"  <---- name of my colonnes
"zzz";"kkk";12,3
"nnn";"lll";8,3

could you please give me an exemple with a vb source

thank you a lot
Ralph - 09 Feb 2008 17:51 GMT
> hello,
>
[quoted text clipped - 10 lines]
>
> thank you a lot

It isn't clear if you are using free-standing VB, or VBA inside MSAccess.
Importing the data is similar with either case, but creating a new table
will differ. If using MSAccess VBA you have additional opportunities which
are likely better than using ADO - for example, you might simply "link" to
the external file and use a Make Table Query.

So if using VBA you should post to a MSAccess newsgroup.

If using a free-standing VB program Google for examples "MS Access ADO
import data file" and "ADOX" (for creating new tables). There are a ton of
possible methods. Find something that looks like it answers your problem,
then post back with code if you get stuck.

hth
-ralph
Dave - 13 Feb 2008 18:07 GMT
I would like import a text file with delimited semi-colon (;) but not with
comma (,)
When I run the VB source it's not ok. It's ok only with comma
Do you have a solution please

My Texte file
---------------
"F1";"F2";"F3"
"3"; "5"; "6"
"1";"2"; "3"
"1,5";"2,4";"3,6"

My Source
------------
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim PathtoTextFile As String
Dim PathtoMDB As String
Dim myarray() As Variant

Private Sub Form_Load()
 PathtoTextFile = "C:\"
 PathtoMDB = "C:\"
 CmdOpen.Caption = "Open textfile and display field value"
 CmdInsert.Caption = "Insert textfile values into MDB"
End Sub

Private Sub CmdInsert_Click()
 Set Cat = New ADOX.Catalog
 Set objTable = New ADOX.Table
 cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
         "Data Source=" & PathtoMDB & "test.mdb"
 'Open the Catalog
 Set Cat.ActiveConnection = cn
 'delete the table if it exists
 On Error Resume Next
 Cat.Tables.Delete "Table1"
 'Create the table
 objTable.Name = "Table1"
 'Create and Append a new fields to the "table1" Columns Collection
 objTable.Columns.Append "F1", adWChar
 objTable.Columns.Append "F2", adWChar
 objTable.Columns.Append "F3", adWChar

 Cat.Tables.Append objTable

 'Insert into table1 the contents of textfile.txt
 cn.Execute "INSERT INTO Table1 SELECT * FROM " & _
            "[Text;Database=" & PathtoTextFile & ";HDR=YES].[TextFile.txt]"
 cn.Close
 MsgBox "Finished Inserting into MDB"
End Sub
Ralph - 13 Feb 2008 18:45 GMT
> I would like import a text file with delimited semi-colon (;) but not with
> comma (,)
> When I run the VB source it's not ok. It's ok only with comma
> Do you have a solution please

Try a schema.ini file.
Open notebook. Type the following:
[TextFile.txt]
Format=Delimited(;)
Save it as "schema.ini" and place it in the same folder as the text file.

Take a look at the following article.
http://support.microsoft.com/kb/262537
Note: you have to change your connection string to include the Delimiter and
Hdr attributes.

Additional information:
http://www.aurigma.com/Support/DocViewer/5/AddingDatafromTextFile.htm.aspx

hth
-ralph
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.