By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,661 Members | 781 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,661 IT Pros & Developers. It's quick & easy.

Syntax error in INSERT INTO statement problem with dataadapter.update

P: 2
well after searching ans coming up with nothing i figured id post something in here to see if i could get some help. i have an access db that keeps track of flights that ive flown. its a logbook basically. now im writing a program to add to that database and for some reason it keeps giving me "Syntax error in INSERT INTO statement" when it comes to the dataadapter.update method. here is the code, i will also include a link to the code with all the goodies highlighted. can someone tell me what im doing wrong? pretty please. hah.

Public Class frmVerifyFlight

Private m_cnADONetConnection As New OleDb.OleDbConnection()
Private m_daDataAdapter As OleDb.OleDbDataAdapter
Private m_cbCommandBuilder As OleDb.OleDbCommandBuilder
Private m_dtlogbook As New DataTable
Private m_rowposition As Integer = m_dtlogbook.Rows.Count



Private Sub frmVerifyFlight_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed

m_cnADONetConnection.Close()
m_cnADONetConnection.Dispose()

End Sub

Private Sub frmAddFlight_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


m_cnADONetConnection.ConnectionString = _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\logbook\db1.mdb"
m_cnADONetConnection.Open()
m_daDataAdapter = _
New OleDb.OleDbDataAdapter("Select * from logbook", m_cnADONetConnection)
m_cbCommandBuilder = New OleDb.OleDbCommandBuilder(m_daDataAdapter)
m_daDataAdapter.Fill(m_dtlogbook)

If txttotal.Text > 24 Then
MessageBox.Show("You can not log more than 24hrs in a day", "Errors Found", MessageBoxButtons.OK, MessageBoxIcon.Error)
frmchangeinfo.ShowDialog()
End If



End Sub

Private Sub btnNo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNo.Click
frmchangeinfo.ShowDialog()

End Sub

Private Sub btnAbort_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAbort.Click
Me.Close()

End Sub

Private Sub rbNo_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

End Sub

Private Sub rbYes_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

End Sub

Private Sub lblcombat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

End Sub

Private Sub lblDescription_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

End Sub

Private Sub txtdescription_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

End Sub

Private Sub btnYes_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnYes.Click

Dim drNewRow As DataRow = m_dtlogbook.NewRow()

drNewRow("FltDate") = txtdate.Text
drNewRow("Aircraft") = txtAircraft.Text
drNewRow("Day") = txtDay.Text
drNewRow("Night") = txtnight.Text
drNewRow("NVD") = txtnvd.Text
drNewRow("Hood") = txthood.Text
drNewRow("TotalTime") = txttotal.Text
drNewRow("Description") = txtdescription.Text
drNewRow("Combat") = rbYes.Checked
m_dtlogbook.Rows.Add(drNewRow)
m_daDataAdapter.Update(m_dtlogbook)

End Sub


End Class

the column names are all listed in the last sub. thanks.
link to highlighted stuff is.......
http://www.nomorepasting.com/getpaste.php?pasteid=3350

thanks
Sep 2 '07 #1
Share this Question
Share on Google+
2 Replies


QVeen72
Expert 100+
P: 1,445
Hi,

looks like ur, m_dtlogBook is a DataTable.. I'am not very sure if Adatpter.Update Can take data table , I have always used that to update a DataSet:

dataAdapter.Update(MyDataSet)

Regards
Veena
Sep 2 '07 #2

P: 2
funny addition to that is that i tried the code out in another simpler program to make sure it would work. and it does. when i transfer it over to this program it doesnt like it for some reason. i dont get it. and there is only one database in the program that im trying to add info to. so i figured a datatable would work best there

Hi,

looks like ur, m_dtlogBook is a DataTable.. I'am not very sure if Adatpter.Update Can take data table , I have always used that to update a DataSet:

dataAdapter.Update(MyDataSet)

Regards
Veena
Sep 2 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.