Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
caterpillar
Starting Member
9 Posts |
Posted - 2006-09-21 : 10:35:15
|
| Hi,I have to insert fields in a table. I am using VB.net & SQL Server database.The code is:Dim var1 As Int32 = Me.classname.UserIDDim strSQLD As String = "Insert into table1 (userid) values (var1)"userid is of type intWhile debugging, i can see that variable var1 is getting the integer value.This is giving Syntax Error:The name 'var1' is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted.Any help is appreciated. |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-09-21 : 10:58:28
|
| If you PRINT strSQLD, what do you see?Doing this might give you a hint of how to solve your problem.The solution is using parameters and stored procedures, but you aren't familiar to that, concatenation might be of use.Peter LarssonHelsingborg, Sweden |
 |
|
|
caterpillar
Starting Member
9 Posts |
Posted - 2006-09-21 : 11:37:05
|
| Hi Guys, Thanks for your replies. I got it like this:Dim strSQLI As String = "Insert into table1 (userid) values (" & Me.Classname.UserID)" RegardsMonica |
 |
|
|
|
|
|