Must declare the scalar variable problem

  • I was a student that need to develop a website with VB 2008, SQL 2005 express edition.

    Here are some of my codings:

    Dim strinsert As String

    Dim con As New SqlConnection("Data Source=)

    Dim cmd As SqlCommand

    strinsert = "INSERT INTO MPInfo (MPMaritalStat, ) values (@MPMaritalStatus)"

    cmd = New SqlCommand(strinsert, con)

    con.Open()

    cmd.Parameters.AddWithValue("@MPMaritalStat", DDLMaritalStatus.SelectedValue)

    But i have this error:

    Must declare the scalar variable "@MPMaritalStatus".

    I need some guidance. So can u pls help me..

    🙂

  • If you can't do that or find out in google, then you are still a student.

    Look up executenonquery in VS2008's help.

  • Yup.. U are very true. I am a student, like i said, that is currently working on my final year project. I will try to look up for solution in the internet.

  • Thanks for the reply 😉

  • I found the silly mistakes i made. ;P.. heeee... The name is not the same with parameters that i declare.

    If i didnt post it here, i would know this mistakes cos i have almost 20 variables, which cos my head to spin.

    thanks to my unprofessional skill in DB.

    Thanks for the guidance Ninja's_RGR'us 🙂

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply