Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm developing vb.net application and receiving error in following code. error is Must declare the scalar variable "@CODE".


VB
Dim load As SearchFromTable = New SearchFromTable
        Dim xcommad As OleDb.OleDbCommand = load.xCommand

        Dim xQry As String = "insert into TBLCLASS (CODE,CNAME,CSEC) Values (@CODE,@CNAME,@CSEC)"

        Try

            With fObjects.CommandObject(xQry, fObjects.ConnectionObject)
                      .Parameters.Add(New OleDb.OleDbParameter("@CODE", OleDb.OleDbType.VarChar, 250)).Value = Me.MTextbox1.Text
                .Parameters.Add(New OleDb.OleDbParameter("@CNAME", OleDb.OleDbType.VarChar, 250)).Value = Me.MTextbox2.Text
                .Parameters.Add(New OleDb.OleDbParameter("@CSEC", OleDb.OleDbType.VarChar, 250)).Value = Me.MCombobox1.Text

                
                load.GetMyData(xQry)
            End With

        Catch ex As Exception
            MsgBox("Failed because: " & ex.Message)

        End Try
Posted
Comments
Arasappan 26-Aug-15 2:48am    
where is ur table

1 solution

According to the documentation[^] you do not need the "@" character when declaring the variable.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900