473,327 Members | 2,118 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Syntax error in INSERT INTO statement problem with dataadapter.update

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
2 4147
QVeen72
1,445 Expert 1GB
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
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

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

Similar topics

14
by: bolidev | last post by:
I'm new to SQL and can't figure out how to update my table (StoreItemStatus) that contains the current status for items in each store (STORE_KEY, ITEM_KEY, STATUS,...). I get updated status info...
4
by: Bob Stearns | last post by:
The statement: merge into nullid.animals_et_in t1 using is3.animals t2 on t1.sire_assoc=t2.assoc and t1.sire_prefix=t2.prefix and t1.sire_regnum=t2.regnum when matched then update set...
3
by: William | last post by:
i am using a dataset and a DataAdapter to update a table with the following schema: ResourceID ProjectID LastName FirstName Year Nov Dec Jan
7
by: kosta | last post by:
hello! one of my forms communicates with a database, and is supposed to add a row to a table using an Insert statement... however, I get a 'oledb - syntax error' exception... I have double...
4
by: Troy | last post by:
We recently installed the .Net framework on a windows 2000 server. Shortly after that we experienced intermitant problems running a web based program that accesses an Access 2002 database. The...
3
by: Jerry | last post by:
Well, here is some weirdness. First, I noticed that I have 2 Set keywords (silly me). so I removed the 2nd "Set" but still got a syntax error. Then I removed the Where clause, and now it works...
1
by: Scott Emick | last post by:
I have the following datatables which are related: Transaction TransactionId-Sequence Orders OrderDetails when I process a daTransaction.update(dtTransaction)...
4
by: =?Utf-8?B?UmljaA==?= | last post by:
On a form - I have a datagridview which is docked to the entire form. The datagridview allows users to Delete and/or Add Rows. On the Form_Load event I Fill the datagridview source table with a...
1
by: AlexW | last post by:
Hi I have been scouring the web for some information regarding how to insert multiple rows at once using an SQL string. I am using an OLEDB dataadapter to communicate with an MS Access DB ...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.