oledbexception was unhandled....syntax error in insert into statement is the error I get I can edit/update information, delete and everything except for add
the cmdSave code is::::
Dim drNewRow As DataRow = m_dtTable1.NewRow()
With Me
drNewRow("id") = .txtid.Text
drNewRow("Date") = .txtdate.Text
drNewRow("Time") = .txttime.Text
drNewRow("CallSign") = .txtcallsign.Text
drNewRow("Freq") = .txtfreq.Text
drNewRow("Mode") = .txtmode.Text
drNewRow("RST") = .txtrst.Text
drNewRow("Notes") = .txtnotes.Text
drNewRow("QslTX") = .txtqsltx.Text
drNewRow("QslRX") = .txtqslrx.Text
End With
m_dtTable1.Rows.Add(drNewRow)
m_daTable1.Update(m_dtTable1) <<<<-----ERROR HERE
m_intRowPosition = m_dtTable1.Rows.Count - 1
m_blnNewRecord = False
m_blnUpdateRecord = False
ShowCurrentRecord()
----------------------------------------------------------------
declarations:::
Public m_cnTable1 As New OleDb.OleDbConnection
Public m_daTable1 As OleDb.OleDbDataAdapter
Public m_cbTable1 As OleDb.OleDbCommandBuilder
Public m_dtTable1 As New DataTable
Public m_intRowPosition As Integer = 0
Public m_blnNewRecord As Boolean = False
Public m_blnUpdateRecord As Boolean = False
----------------------------------------------------------------
I can post full code if need be but I figured going through that much might be enough
7 1211
oledbexception was unhandled....syntax error in insert into statement is the error I get I can edit/update information, delete and everything except for add
the cmdSave code is:::: -
-
Dim drNewRow As DataRow = m_dtTable1.NewRow()
-
-
With Me
-
drNewRow("id") = .txtid.Text
-
drNewRow("Date") = .txtdate.Text
-
drNewRow("Time") = .txttime.Text
-
drNewRow("CallSign") = .txtcallsign.Text
-
drNewRow("Freq") = .txtfreq.Text
-
drNewRow("Mode") = .txtmode.Text
-
drNewRow("RST") = .txtrst.Text
-
drNewRow("Notes") = .txtnotes.Text
-
drNewRow("QslTX") = .txtqsltx.Text
-
drNewRow("QslRX") = .txtqslrx.Text
-
End With
-
-
m_dtTable1.Rows.Add(drNewRow)
-
m_daTable1.Update(m_dtTable1) <<<<-----ERROR HERE
-
-
m_intRowPosition = m_dtTable1.Rows.Count - 1
-
-
m_blnNewRecord = False
-
m_blnUpdateRecord = False
-
-
ShowCurrentRecord()
-
-
-
----------------------------------------------------------------
-
-
declarations:::
-
Public m_cnTable1 As New OleDb.OleDbConnection
-
Public m_daTable1 As OleDb.OleDbDataAdapter
-
Public m_cbTable1 As OleDb.OleDbCommandBuilder
-
Public m_dtTable1 As New DataTable
-
Public m_intRowPosition As Integer = 0
-
Public m_blnNewRecord As Boolean = False
-
Public m_blnUpdateRecord As Boolean = False
-
----------------------------------------------------------------
I can post full code if need be but I figured going through that much might be enough
Greetings!
I have not yet handled insert/update commands in his fashion, but one thing I see is should you also dimension daTable1 as you did here: -
-
Dim drNewRow As DataRow = m_dtTable1.NewRow()
-
-
Also, are you updating to the daTable1 table?
Should you say: -
-
m_daTable1.Rows.Update(m_dtTable1)
-
-
If nothing is working you might consider adding a different code to add. Something I am actually working on, works great. disregard if your works for you: -
-
Dim my_database As Database
-
Dim my_record As Recordset
-
Set my_database = OpenDatabase("C:\DataGram\Data_Central.mdb")
-
Set my_record = my_database.OpenRecordset("select * from Employee where Your_Price='" & Text1(0).Text & "'")
-
my_record.Edit
-
my_record!Your_Price = Text1(0).Text
-
my_record!Name = Text1(1).Text
-
my_record!Crime_Rate_1 = Text1(2).Text
-
my_record!Crime_Rate_2 = Text1(3).Text
-
my_record!Type = Text1(4).Text
-
-
my_record.Update
-
my_record.Close
-
my_database.Close
-
-
End If
-
-
End Sub
-
Still try adding Rows.Update to the line mentioned, okay.
In a bit!
Dököll
Nevermind, I think you're refering to Insert, you must Add Insert, not Update, so perhaps Rows.Insert, or simply Insert, instead of Update, my apologies. I thought you were having issues updating when I read that portion of the code.
See if that works:-)
I replaced m_dtTable1.Rows.Add(drNewRow) with m_dtTable1.Rows.InsertAt(drNewRow, m_dtTable1.Rows.Count + 1)
still same error
m_daTable1.InsertCommand is the only insert available to me and that doesnt seem to be the right way to go either...thisis sooo frustrating, so close to finishing but yet soo far
I think you are using reserved words as field names in the database (i.e. "Date" and "Time") try puting square brackets around those two words in your code, like so "[Date]" "[Time]" or you can change the field names (in the database) to somthing like "EventDate" and "EventTime". When using reserved words as field names in a database you have to use square brackets when using those field names in your query/code. There is a long list reserved words, here is a link to a list. http://support.microsoft.com/kb/286335
Notes: you are also using "Notes" which is not a reserved word but "Note" is also "ID" is not on the list but I imagin it could give you problems. I would recomend (if possable) to change those field names as well. I hope this helps!
Torgg
changed date to ddate same thing will work on the other fields and see how it goes
WOOOHOOO
changed id date time and notes left all other fields the same and bingo worked best kind
leave it to me to pick names that are reserved
thank you soooooooooOOOOOOOOOOOOOOooooooooooooo much, this has been a 2 week battle
thankyou thankyou thankyou thankyou thankyou thankyou thankyou thankyou thankyou thankyou thankyou thankyou thankyou thankyou thankyou thankyou
I'm so glad I could help... take care!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jack |
last post by:
I have a text file of data in a file (add2db.txt) where the entries are
already entered on separate lines in the following form:
INSERT INTO `reviews` VALUES("", "Tony's", "Lunch", "Great...
|
by: ImraneA |
last post by:
Hi there
Application : Access v2K/SQL 2K
Jest : Using sproc to append records into SQL table
Jest sproc :
1.Can have more than 1 record - so using ';' to separate each line
from each other.
|
by: iqbal |
last post by:
Hi all,
We have an application through which we are bulk inserting rows into a
view. The definition of the view is such that it selects columns from
a table on a remote server. I have added the...
|
by: Karen Middleton |
last post by:
In MS Access I can do in one SQL statement a update if exists else a
insert.
Assuming my source staging table is called - SOURCE and my target
table is called - DEST and both of them have the...
|
by: Philip Boonzaaier |
last post by:
I want to be able to generate SQL statements that will go through a list of
data, effectively row by row, enquire on the database if this exists in the
selected table- If it exists, then the colums...
|
by: Kragen Sitaker |
last post by:
ERROR: Cannot insert a duplicate key into unique index pg_class_relname_nsp_index
We've been getting this error in our application every once in a while
--- typically once an hour to once a day,...
|
by: harborboy76 |
last post by:
Hi,
I am trying to insert a large number of rows into a table
inside a SPL. But every time, I run the SPL, the table is
locked because of the INSERT. When I tried to issue a COMMIT,
right after...
|
by: harborboy76 |
last post by:
Hi,
I had posted one topic earlier, but somehow the link
has been broken and I cannot see the topic. So sorry if
this is a duplicate topic for some. Here is the issue
that I'm running into....
|
by: technocraze |
last post by:
Hi guys,
I have encountered this error when updating the values to the MS Acess table.
Error : Update on linked table failed. ODBC sql server error Timeout expired. MS Acess is my front end and...
|
by: rn5a |
last post by:
During registration, users are supposed to enter the following
details: First Name, Last Name, EMail, UserName, Password, Confirm
Password, Address, City, State, Country, Zip & Phone Number. I am...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |