i have this query that works nice to insert data in aaccess db, but now im trying to insert on a sqllite3 db but im having trouble using the same query
Imports System.Data.Odbc
Public Class Form1
Public con As New OdbcConnection("Dsn=SQLite3 Datasource;database=C:\Users\pcampos\Desktop\spiceworks_prod.db;stepapi=0;syncpragma=NORMAL;notxn=0;timeout=100000;shortnames=0;longnames=0;nocreat=0;nowchar=0;fksupport=0;oemcp=0;bigint=0")
Dim query As String = "INSERT INTO INSERT INTO tickets(id, summary, status) VALUES(@id,@summary,@status )"
con.Close()
con.Open()
Using cmd As New OdbcCommand(query, con)
cmd.Parameters.AddWithValue("@id", OdbcType.VarChar).Value = test
cmd.Parameters.AddWithValue("@sumamry", OdbcType.VarChar).Value = "ola ola ola"
cmd.Parameters.AddWithValue("@staus", OdbcType.VarChar).Value = "close"
Dim x As Integer = cmd.ExecuteNonQuery()
MsgBox(x)
If x < 1 Then
MessageBox.Show("Erro ao inserir", My.Application.Info.Title, MessageBoxButtons.OK, MessageBoxIcon.Error)
Else
MessageBox.Show("Registo1 inserido com sucesso!", My.Application.Info.Title, MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End Using
End Class
That query is not valid SQL. It should be something like this:
See the SQLite Insert Query Manual for a diagram detailing the order of key words in an SQL Insert statement. The SQL would be an error on other SQL based systems, not just SQLite. Just thought I’d linke to that manual page as it is very useful.