I’ve got some problems.
I’ve got this code:
Dim infoID As Integer = objCommand1.ExecuteScalar()
Dim strSQL2 As String = "insert into feedBackHotel (infoID, feedBackView) values(" + infoID + ",'" + FeedBack + "')"
Dim objCommand2 As New SqlCommand(strSQL2, conn)
objCommand2.ExecuteNonQuery()
The problem here is..the strSQL2 can capture the infoID from the previous statement,
but it didn’t insert into the database. It will pop out this error:
“Conversion from string “insert into feedBackHotel (infoI” to type ‘Double’ is not valid.”
in both table related, use same data type (int)
but for the feedBackHotel’s infoID I allow it to be null..because if I make it not null, it will show another error..
I’m using VB.NET ..Can anyone help?
You’re attempting to concatenate a double to a string, which is causing your error. You’re also building unparameterized SQL statements, which is a deadly sin. Using parameters will solve both your problems. Try something like this: