mangojack Expert Licensed User Longtime User Jan 16, 2013 #1 I cannot find any positive yes or no on this. Is it possible to to reference an SQL table by way of variable. ie: Dim Tname as string : "MyReports" SQL1.ExecNonQuery ("INSERT INTO "' & Tname & "' VALUES (NULL, "somedata)") Cheers mj
I cannot find any positive yes or no on this. Is it possible to to reference an SQL table by way of variable. ie: Dim Tname as string : "MyReports" SQL1.ExecNonQuery ("INSERT INTO "' & Tname & "' VALUES (NULL, "somedata)") Cheers mj
klaus Expert Licensed User Longtime User Jan 16, 2013 #2 Sure you can ! But you must change the query from Code: Copy SQL1.ExecNonQuery ("INSERT INTO "' & Tname & "' VALUES (NULL, "somedata)") to: Code: Copy SQL1.ExecNonQuery ("INSERT INTO " & Tname & " VALUES (NULL, somedata)") or : Code: Copy SQL1.ExecNonQuery ("INSERT INTO " & Tname & " VALUES (NULL, '" & somedata & "') No single quotes and in your example the first single quote should have been before the double quote. The double quote before somedata is wrong too. The example in the User's Guide uses a variable for the table name. Best regards. Upvote 0
Sure you can ! But you must change the query from Code: Copy SQL1.ExecNonQuery ("INSERT INTO "' & Tname & "' VALUES (NULL, "somedata)") to: Code: Copy SQL1.ExecNonQuery ("INSERT INTO " & Tname & " VALUES (NULL, somedata)") or : Code: Copy SQL1.ExecNonQuery ("INSERT INTO " & Tname & " VALUES (NULL, '" & somedata & "') No single quotes and in your example the first single quote should have been before the double quote. The double quote before somedata is wrong too. The example in the User's Guide uses a variable for the table name. Best regards.
mangojack Expert Licensed User Longtime User Jan 16, 2013 #3 Thanks Again Klaus.. I was aware of the somedata syntax , just messy in my example. Cheers mj Upvote 0