TravisW
February 18th, 2000, 02:13 PM
OK, this is probably a rookie question...but then again I am a rookie. I have written code that gathers a recordset and reads each field (the recordset consists of the one field) one at a time. What I need to do is to have the data (which is a string) be written to another table, which also only has the one field. I have already defined an str to get the string out of the table it is currently in. I just need to get it written to this other table. ANy help would be greatly appreciated.
Johnny101
February 18th, 2000, 03:00 PM
Any time you're writing string data types to a table in either Access, or SQL Server (i don't know about oracle) you have to surround the data with single tick marks, like this:
Dim str as string
str = "INSERT INTO MyTable (StrField) VALUES ('MyData Goes Here')"
'and then execute this statement.
when you are using a variable (like you are) you still have to surround the actual data with single ticks marks, but the difference is, with a variable you want the variable's data, not the variable name to be inserted into the table, so you in your sql statement, you have to stop the quotation and append the variable's value and then append the closing tick mark after that. Like this:
Dim str as string
str = "INSERT INTO MyTable (StrField) VALUES ('" & sVariable & "')"
'and execute this.
Hope this helps/makes sense,
John
John Pirkey
MCSD
www.ShallowWaterSystems.com
TravisW
February 18th, 2000, 04:14 PM
John, thanks for the help...it works like a charm!!