vb.net内では、以下のコードが機能します
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
しかし、数字3を挿入する代わりに整数変数を入れたいと思います。私はこれを試しました:
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
しかし、私には例外があります:
Conversion from string "insert into Notes(isFirst" to type 'Double' is not valid.
私は次の行を知っています:
"insert into Notes(num , name ) VALUES(" + count + ", 'Bob') "
完全に間違っているようですが、すべて試したので、他の解決策は見つかりません。
カウント変数をテーブルに挿入するにはどうすればよいですか?
前もって感謝します。