Hi,
How do I use insertparameters in code-behind? This is the code that I have
Dim insertSqlAs StringinsertSql ="INSERT INTO [xyzTable] ([x], [y]) VALUES (@.x, @.y)"SqlDataSource1.InsertCommand = insertSqlSqlDataSource1.InsertParameters.Add("@.x","124")SqlDataSource1.InsertParameters.Add("@.y","456")SqlDataSource1.Insert()
When I execute these line of code I get an error saying
"Must declare the variable '@.x'."
Please help
I assume your code block is under button click event:
Protected Sub Button1_Click(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles Button1.Click
Dim insertSqlAs String
insertSql ="INSERT INTO [xyzTable] ([x], [y]) VALUES (@.x, @.y)"
SqlDataSource1.InsertCommand = insertSql
SqlDataSource1.InsertParameters.Add("x","124")
SqlDataSource1.InsertParameters.Add("y","456")
SqlDataSource1.Insert()
End Sub
ADO.NET parameter and ASP.NET parameter are different. ADO.NET parameters always start with @. sign.
|||That simple -- just remove the @. sign. Thanks for your help