add details to form

ritesh21

Member
Joined
Jan 21, 2008
Messages
7
Programming Experience
Beginner
Hi 2 all,
Am trying to add details from a VB form to an ms access database using the following code:

strsql = "Insert Into Admin Values ('" &g_login& "', '"&strpass&"');"

I've already declared the DB connection path and strsql is declared as a String.
Yet, from the above code i'm getting the following errors:

1.it's asking for end of statement
2.for the &....& part its saying not applicable to String type

The g_login and strpass are 2 global variables capture values from my 2 textboxes in the form, which take any characters.

If am replacing the '"&....&"' part by e.g. 'Joe', its working ok.

Can anyone plz help...
Regards
 
You have to use parameters, see for example this post.
 
Thx 4 the help, but the code is working correctly now. It seems that the "&" sign must be separated from the variables. My new code looks like this now:

strsql = "Insert Into Admin Values (' " & txtX.Text & "', ' "& txtY.Text &" ')
 
You can lead a horticulture but you can't make her think. :p
 
I give up..

Never give up. If you only ever convince one person to change their ways, then you've succeeded.

Oh, and up until recently, I had been writing queries like that for years. Now, PQ every time :D
 
So.. I convinced one person? (You)
Hurrah!

What i'm actually more stunned about (and in a fall-off-chair way); JohnH just used a smiley! ;)
 
Back
Top