Inside vb.net the code below works
cmd.CommandText = "CREATE TABLE Notes ( num INTEGER, name TEXT)"
Try
cmd.ExecuteNonQuery()
Catch ex As Exception
MsgBox("Error during save operation: " & ex.Message)
End Try
cmd.CommandText = "insert into Notes(num , name ) VALUES( 3, 'Bob') "
Try
Console.WriteLine(cmd.ExecuteNonQuery())
Catch ex As Exception
MsgBox("Error during save operation: " & ex.Message)
End Try
But I want to put an Integer variable instead of inserting the number 3. I tried this :
Dim count As Integer = 1
cmd.CommandText = "insert into Notes(num , name ) VALUES(" + count " + , 'Bob') "
Try
Console.WriteLine(cmd.ExecuteNonQuery())
Catch ex As Exception
MsgBox("Error during save operation: " & ex.Message)
End Try
But then I have the exception:
Conversion from string "insert into Notes(isFirst" to type 'Double' is not valid.
I know that the line:
"insert into Notes(num , name ) VALUES(" + count + ", 'Bob') "
seems to be totally wrong but I cannot find any other solution, since I tried them all.
How can I insert the count variable into the table?
Thanks in advance.