insert new record into SQL not working

Hi

I am trying to create a small software license database and when i try and insert a new record using


        Dim connstring As String = Nothing

        Dim sqlconn As New SqlConnection
        Dim sqlcmd As New SqlCommand

        connstring = "server=simon-pc;database=licenses;trusted_connection=yes;"

        sqlconn.ConnectionString = connstring

        sqlconn.Open()
        sqlcmd.Connection = sqlconn

        sqlcmd.CommandText = "insert into licenses (Manuafacture, appname, version, username, ci, license, po, invoice, date_logged) values(" & manufacturerCb.SelectedValue & "," & _
            applicationNameCb.SelectedValue & "," & verstionTxt.Text & "," & assignedUserTxt.Text & "," & machineNameTxt.Text & "," & licenseKeyTxt.Text & "," & poNumberTxt.Text & "," & _
            invoiceNumberTxt.Text & "," & dateloggedDtp.Value & ");"


        sqlcmd.ExecuteNonQuery()
        sqlconn.Close()



I receive the error message

Incorrect syntax near ','.

using VS2010 in the autos window the last place this gets to is version.

Can anyone shed any light on to why I am getting this please?

Thanks

Simon
SimonPrice33Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
pdd1lanConnect With a Mentor Commented:
you might need to put a single quote around the text value


sqlcmd.CommandText = "insert into licenses (Manuafacture, appname, version, username, ci, license, po, invoice, date_logged) values(' " & manufacturerCb.SelectedValue & " ' , ' " & _
            applicationNameCb.SelectedValue & " ', ' " & verstionTxt.Text & " ', ' " & assignedUserTxt.Text & " ', ' " & machineNameTxt.Text &  " ', ' " & licenseKeyTxt.Text & " ', ' " & poNumberTxt.Text & " ', ' " & _
 invoiceNumberTxt.Text & " ' , #" & dateloggedDtp.Value & "# );"
0
 
Paul JacksonSoftware EngineerCommented:
Have you spelt this control correctly ? verstionTxt.Text
Are you maybe missing a continuation character after the & on the 3rd line
0
 
SimonPrice33Author Commented:
thanks guys, will try now, spelling of version is correct now...  will try using the single quotes too...

one question, what does the # represent?

Thanks
Simon
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
SimonPrice33Author Commented:
Bonza! thanks :)

worked a charm with single quotes, changed the # to ' too :)

thanks

Simon
0
 
pdd1lanCommented:
you don't have to use a sing quote around value if value is number, but it requires the value is text value.  "#" around variable for date field value.
0
 
SimonPrice33Author Commented:
hi, the spelling mistake was in my post here, actual code was correct, solution that was awarded the points was the correct and in full..
0
All Courses

From novice to tech pro — start learning today.