Hi All,
Can't insert data into SQL database... Keep getting error i dont know how to solve...
Plz help
Grtz Tiello
CODE:
--------------------------------------------------------------------------------------
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim connetionString As String
Dim connection As SqlConnection
Dim adapter As New SqlDataAdapter
Dim sql As String
connetionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\mydatabase.mdf;Integrated Security=True;User Instance=True"
connection = New SqlConnection(connetionString)
sql = "insert into tb_klanten (Klant_ID,Contactpersoon,geslacht,adres,postcode,woonplaats,land,telefoonnummer,faxnummer,emailadres,naam_administratief_contactpersoon,administratief_emailadres, administratief_telefoonnummer,bankgironummer,uname,upass) values(textbox1.text,@dropdownlist1.text,@textbox3.text,@textbox4.text,@textbox4.text,@textbox5.text,@textbox6.text,@textbox7.text,@textbox8.text,@textbox9.text,@textbox11.text,@textbox12.text,@textbox13.text,@textbox10.text,@textbox14.text,@textbox15.text)"
Try
connection.Open()
adapter.InsertCommand = New SqlCommand(sql, connection)
adapter.InsertCommand.ExecuteNonQuery()
label1.Text = "Gebruiker aangemaakt!"
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
--------------------------------------------------------------------------------------
ERROR:
System.Data.SqlClient.SqlException: Must declare the scalar variable "@dropdownlist1".
at System.Data.SqlClient.SqlConnectrion.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
etc. etc.
--------------------------------------------------------------------------------------