Link to home
Start Free TrialLog in
Avatar of PNRT
PNRT

asked on

In VB.Net - Trying to insert variables into MSSQL

Hi Experts, In vb.net I am connecting to a MS SQL 2005 Database and inserting the following-
objCommand = New SqlCommand("Insert Into Bookings(Guest, Bnumber, Cumber) Values(" & " '1', '2', '3')")  This works correctly.   But when I substitue my variables into the "Values", I get the error message "The name "xxxx" is not valid in this context.   I think I'm getting my " " and ' ' mixed up.   Please can someone show me the syntax for multiple variables in the SQL command in .net.  Thanks in advance
ASKER CERTIFIED SOLUTION
Avatar of lazyberezovsky
lazyberezovsky
Flag of Belarus image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry, you should not wrap INTEGERS, not strings. See example above.
Avatar of PNRT
PNRT

ASKER

Sorry, the 1 2 and 3 were just example variables, not integers.
But your solution worked first time
Many Thanks