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!

Concatenating variables in SQL query

Status
Not open for further replies.

solostar

Technical User
Jan 18, 2004
10
0
0
SG
SqlString = "SELECT Start1, End1, Start2, End2, Start3, End3, Start4, "
"End4, Start5, End5, Start6, End6, Start7, End7, Start8, End8, "
"Start9, End9, Start10, End10, Start11, End11, Start12, End12 "
"FROM BANDSETTING "
"WHERE BANDNAME = &",
" &m_Store ";

Hi... the above is my code. m_Store is the variable i want to concatenate.
but it doesnt work the way i want it. what's wrong?? =)

by the way, im not using VBA...

this query is called in the windows application accessing the database.

 
This looks like code to me. If you aren't using VBA then what are you using? You are missing any lots of required "stuff". I would expect to see something like:
[blue]
Code:
SqlString = "SELECT Start1, End1, Start2, End2, Start3, End3, Start4, " & _
"End4, Start5, End5, Start6, End6, Start7, End7, Start8, End8, " & _
"Start9, End9, Start10, End10, Start11, End11, Start12, End12 " & _
"FROM BANDSETTING " & _
"WHERE BANDNAME = """ & m_Store """;"
[/blue]
This assumes BANDNAME is a text field.
The highly un-normalized table structure might be a major concern but I will assume you have a good reason for the repeating fields.


Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
Thanks very much!
But i have found a way that works...
=)

SqlCommand = "INSERT INTO BandSetting "
"VALUES('" + str25 + "'" ",'" + str1 + "'" ",'" + str2 + "'"
",'" + str3 + "'" ",'" + str4 + "'" ",'"+ str5 + "'" ",'"+ str6 + "'" ",'" + str7 + "'" ",'" + str8 + "'" ",'"+ str9 + "'" ",'" + str10 + "'" ",'" + str11 + "'" ",'"+ str12 + "'" ",'" + str13 + "'" ",'" + str14 + "'" ",'" + str15 + "'" ",'" + str16 + "'" ",'" + str17 + "'" ",'"+ str18 + "'" ",'" + str19 + "'" ",'" + str20 + "'" ",'"+ str21 + "'" ",'" + str22 + "'" ",'" + str23 + "'" ", + str24 + "'" ")" ;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top