n2amg
06-11-2012, 10:34 AM
I have a very simple database with 7 fields.
Index-AutuNumber
Callsign - Text
Freq - Double
TS - Text
QSXFreq - Double
Comment - Text
Spotter - Text
Band - Integer
Here is the routine I am using.
Public Sub AddSpot(ByVal Callsgn As String, ByVal Freq As Double, ByVal TS As String, ByVal QSXFreq As Double, ByVal Comments As String, ByVal Spotter As String, ByVal Band As Integer)
Dim SQL As String
Dim objCmd As New OleDb.OleDbCommand
Dim Con = New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source = " & Application.StartupPath & "\FldigiDXCluster.mdb")
If Comments = "" Then Comments = "nothing"
Try
Con.Open()
SQL = "Insert into Spots (Callsign, Freq, TS, QSXFreq, Comments, Spotter, Band) VALUES ('" & Callsgn & "', '" & Freq & "', '" & TS & "', '" & QSXFreq & "', '" & Comments & "', '" & Spotter & "', '" & Band & "')"
objCmd = New OleDb.OleDbCommand(SQL, Con)
objCmd.ExecuteNonQuery()
Con.Close()
Catch ex As Exception
MessageBox.Show(ex.Message & " - " & ex.Source)
Con.Close()
End Try
End Sub
The result from a breakpoint SQL= this:
?SQL
"Insert into Spots (Callsign, Freq, TS, QSXFreq, Comments, Spotter, Band) VALUES ('EO2012JT', '14189', '1630Z', '0', 'tnx QSO', 'R9UAG', '20')"
But every time the routine is run I get :
Syntax error in INSERT INTO Statement - Microsoft Jet Database Engine.
I have tried with and without ' around fields with numbers but I cannot figure it out..
TIA
Rick
Index-AutuNumber
Callsign - Text
Freq - Double
TS - Text
QSXFreq - Double
Comment - Text
Spotter - Text
Band - Integer
Here is the routine I am using.
Public Sub AddSpot(ByVal Callsgn As String, ByVal Freq As Double, ByVal TS As String, ByVal QSXFreq As Double, ByVal Comments As String, ByVal Spotter As String, ByVal Band As Integer)
Dim SQL As String
Dim objCmd As New OleDb.OleDbCommand
Dim Con = New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source = " & Application.StartupPath & "\FldigiDXCluster.mdb")
If Comments = "" Then Comments = "nothing"
Try
Con.Open()
SQL = "Insert into Spots (Callsign, Freq, TS, QSXFreq, Comments, Spotter, Band) VALUES ('" & Callsgn & "', '" & Freq & "', '" & TS & "', '" & QSXFreq & "', '" & Comments & "', '" & Spotter & "', '" & Band & "')"
objCmd = New OleDb.OleDbCommand(SQL, Con)
objCmd.ExecuteNonQuery()
Con.Close()
Catch ex As Exception
MessageBox.Show(ex.Message & " - " & ex.Source)
Con.Close()
End Try
End Sub
The result from a breakpoint SQL= this:
?SQL
"Insert into Spots (Callsign, Freq, TS, QSXFreq, Comments, Spotter, Band) VALUES ('EO2012JT', '14189', '1630Z', '0', 'tnx QSO', 'R9UAG', '20')"
But every time the routine is run I get :
Syntax error in INSERT INTO Statement - Microsoft Jet Database Engine.
I have tried with and without ' around fields with numbers but I cannot figure it out..
TIA
Rick