Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Insert SQL

Status
Not open for further replies.

sidanshu

Programmer
Aug 21, 2001
29
0
0
CA
I have a situation when i want to insert some selected columns in the database.
Talking about one column, i have the column name and its value stored in two variable say
strcolnames = strcolnames + ", city_name" and
its value stored in a variable , say strcolvalue
now to make my sql i collect all selected parameters through another strparameters variable and i want somethimg like
strparameters = strparameters + '" & strcolvalue & "' and so on

so that final sql looks like
finalsql = "Insert into table_name(" & strcolname ") values ( " & strparameters

what i want is that strparameters should store the parameter names with ampersand and quotes signs and get eveluated only at final sql runtime, but what i get now is that they already get evaluated because of & character and i can not see the latest values in the sql - parameters get values later on .. after
strparameters = ..... - statement

i think its a very simple problem somewhere- trying to store the string with & character..
Anyone - please help.
Anshu


 
Anshu,

I have had similar problems and what I decided was that you can't add a double quote into a string variable ("). You can add a single quote into a string variable tho (').
I think you are running into the same problem.

You might have to quote the & to make it work also.


It may be easier to get your information into the separate variables then at the end concatenate the sql statement all at once instead of adding it into a string var piece by piece.

Hope it helps!!

Splaisance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top