I want to upload a text file to a access database, but the string does not work. I guess the problem is with the quote marks or something of the sort.

The string is as follows:

rs.Open "SELECT * FROM [" & Me.Text1.Text & "] ", objConnection, adOpenStatic, adLockOptimistic, adCmdText

Text1.text is contains the name of the file to be put into the database.

Thanks

Its little confusing. Is Text1 a Text box or Text file which id usually saved as .txt file? Secondly your SELECT statement is not correct.

thanks

The correct way would be as follow -

Dim strMyTableName As String

strMyTableName = Text1.Text 'Or if you get the string from another form..
'strMyTableName = frm...Text1.Text

 rs.Open "SELECT * FROM " & strMyTableName & "", objConnection, adOpenStatic, adLockOptimistic, adCmdText 'Only use the "[]" if your table name has spaces between them, as in - My Table Name

I hope this solves your problem.

Kinwang, Andre,...

>Text1.text is contains the name of the file to be put into the database.

Mr. Nervous is trying the insert the contents of a text file into the database, but as you can see from his select statement, and if you think about the logic here, you will see where Mr. Nervous is having his problems....

Mr. Nervous,

First of all you need to open the file and read its contents in. Please look up the following on the index tab of the help files and don't forget to look at the examples.

FreeFile Function
Open Statement
Input Function
Line Input Function
Close Statement

Then, use your new best friends (yahoo, google, ask, answers, bing) to search for vb6 ado tutorial.

So your process would be something like this pseudo code...

read file in
open connection to database if not already open
prepare sql insert statement
execute sql insert statement with the connection objects execute method

Good Luck

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.