|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I get the following error upon executing an INSERT.
(I am using vb.net) The name 'x' is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted. . My code looks like: dim x as integer = 5 Dim cmd As New SqlCommand("INSERT INTO Restaurants (RestName, Street, TownID, Town, County, PostCode, Telephone, CuisineType, RankPriority, BriefDesc, PhotoUrl, MealDealDetails) VALUES('" & RestNameTxt.Text & "','" & StreetTxt.Text & "',x,'" & TownTxt.Text & "','" & CountyTxt.Text & "','" & PostCodeTxt.Text & "','" & TelephoneTxt.Text & "',5,5,'" & BriefDescTxt.Text & "','" & PhotoUrlTxt.Text & "','" & MealDealDetailsTxt.Text & "')", New SqlConnection(strConn)) cmd.Connection.Open() cmd.ExecuteNonQuery() cmd.Connection.Close() Please can anyone help? Why can't I include a simple variable, x, in the Insert? Thanks Jonnieay ![]() |
|
#2
|
|||
|
|||
|
hi
use this
****& StreetTxt.Text & "'," & x &" ', " & TownTxt.Text & "','" **** i mean to say just replace & "',x,'" & with " '," & x &" ', " let me know the result dipit |
|
#3
|
|||
|
|||
|
Thank you very much,
,"& x &", It works! You've made my day. |
![]() |
| Viewing: ASP Free Forums > Database > SQL Development > How do I insert an integer variable into an INSERT |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|