473,386 Members | 1,758 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,386 software developers and data experts.

Problem updating a database :(

I have a slight problem updating a table in a database (vb.net)

my code looks like the following

Dim new_row As DataRow = {datatable}.NewRow
..
..
..
//the following are the only columns in my table//
line 1: new_row("coming_from") = "1000"
line 2: new_row("text") = "blah blah blah"
line 3: new_row("going_to") = "-1"
line 4: new_row("solution") = true
line 5: new_row("q_a_s") = "answer"

line 6: {data_table}.Rows.Add(new_row)

line 7: {data_adapter}.Update(data_table)***

This is where I am having a problem (Line 7). My database has about 5
tables and all of them have been updated in some fashion, all in this
exact manner and have worked perfectly - but this one won't.

I've checked the datatable in the command window after line 6 has
completed and the new row has been added and all the data is correct.
However when the prog reaches line 7 it gives the following error
message:

"An unhandled exception of type 'System.Data.OleDb.OleDbException'
occurred in System.data.dll"

When I use the command window and type in "?
{data_adapter}.Update(data_table)" I get the following message:

"Run-time exception thrown : System.Data.OleDb.OleDbException - Syntax
error in INSERT INTO statement."

What this means I just do not know and am hoping that somebody here can
help me?

As I've used the same method of code as when trying to update other
tables I assumed it should work but it just doesn't want to :(

thanks,

Steve

Jan 2 '06 #1
5 1233
"SteMc" <go****@jasmonio.supanet.com> schrieb
//the following are the only columns in my table//
line 1: new_row("coming_from") = "1000"
line 2: new_row("text") = "blah blah blah"

[...]

"Run-time exception thrown : System.Data.OleDb.OleDbException -
Syntax
error in INSERT INTO statement."

What this means I just do not know and am hoping that somebody here
can
help me?


It means that you didn't enclose the field name "text" in square brackets:

insert into bla (coming_from, [text], ....) values (...)
If you use a Commandbuilder, set it's quoteprefix and quotesuffix properties
to "[" and "]".
Armin

Jan 2 '06 #2
Steve,

I wonder if one of your column names, perhaps "text", is a reserved word and
must therefore be placed inside square brackets: [text], for example.

Kerry Moorman
"SteMc" wrote:
I have a slight problem updating a table in a database (vb.net)

my code looks like the following

Dim new_row As DataRow = {datatable}.NewRow
..
..
..
//the following are the only columns in my table//
line 1: new_row("coming_from") = "1000"
line 2: new_row("text") = "blah blah blah"
line 3: new_row("going_to") = "-1"
line 4: new_row("solution") = true
line 5: new_row("q_a_s") = "answer"

line 6: {data_table}.Rows.Add(new_row)

line 7: {data_adapter}.Update(data_table)***

This is where I am having a problem (Line 7). My database has about 5
tables and all of them have been updated in some fashion, all in this
exact manner and have worked perfectly - but this one won't.

I've checked the datatable in the command window after line 6 has
completed and the new row has been added and all the data is correct.
However when the prog reaches line 7 it gives the following error
message:

"An unhandled exception of type 'System.Data.OleDb.OleDbException'
occurred in System.data.dll"

When I use the command window and type in "?
{data_adapter}.Update(data_table)" I get the following message:

"Run-time exception thrown : System.Data.OleDb.OleDbException - Syntax
error in INSERT INTO statement."

What this means I just do not know and am hoping that somebody here can
help me?

As I've used the same method of code as when trying to update other
tables I assumed it should work but it just doesn't want to :(

thanks,

Steve

Jan 2 '06 #3
Briliant! I tried changing the column heading from "text" to
"desired_text" and it worked perfectly.

I've encountered a few problems with the database but I didn't even
consider the problem of reserved words, good stuff :)

thank you both for your help,

Steve

Jan 2 '06 #4
On 2 Jan 2006 12:09:10 -0800, "SteMc" <go****@jasmonio.supanet.com>
wrote:
Briliant! I tried changing the column heading from "text" to
"desired_text" and it worked perfectly.

I've encountered a few problems with the database but I didn't even
consider the problem of reserved words, good stuff :)

thank you both for your help,

Steve


For future reference: SQL Server, ODBC, and future keywords:
http://msdn.microsoft.com/library/de...ra-rz_9oj7.asp

Add to that the data types (including "text").

Merging those lists with similar lists for Oracle, MySQL, Access, etc.
should help prevent problems in the future if the system should ever
support those as well.

Note: QuotePrefix/QuoteSuffix are new in .Net 2.0, hence not available
in 2002/2003 (version was not specified).

/JB

Jan 2 '06 #5
Joergen Bech <jbech<NOSPAM>@ wrote:
On 2 Jan 2006 12:09:10 -0800, "SteMc" <go****@jasmonio.supanet.com>
wrote:

Briliant! I tried changing the column heading from "text" to
"desired_text" and it worked perfectly.

I've encountered a few problems with the database but I didn't even
consider the problem of reserved words, good stuff :)

thank you both for your help,

Steve

For future reference: SQL Server, ODBC, and future keywords:
http://msdn.microsoft.com/library/de...ra-rz_9oj7.asp

Add to that the data types (including "text").

Merging those lists with similar lists for Oracle, MySQL, Access, etc.
should help prevent problems in the future if the system should ever
support those as well.

Note: QuotePrefix/QuoteSuffix are new in .Net 2.0, hence not available
in 2002/2003 (version was not specified).

/JB


Also if you ran the query in Query Analyzer it would have told you the
issue.

Chirs
Jan 3 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Frnak McKenney | last post by:
I'm using an in-core DataSet as an image of my application's 'database' (a multi-table Access97 mdb file). Updates are made to the DataTables within the DataSet via forms with bound TextBoxes,...
1
by: Steven Blair | last post by:
Hi, Here is a short decsription of my problem. I have written a dll for Database accessing. I have one method which can return a Dataset and another method which takes a Dataset and upates a...
1
by: delta7 | last post by:
Hi, I'm new to C sharp and currently writing a small program that uses an Access 2003 database. I am currently having a problem when updating a row that includes numeric data. When updating...
5
by: junglist | last post by:
Hi guys, I've been trying to implement an editable datagrid and i have been succesful up to the point where i can update my datagrid row by row. However what used to happen was that once i updated...
14
by: Lars Netzel | last post by:
A little background: I use three Datagrids that are in a child parent relation. I Use Negative Autoincrement on the the DataTables and that's workning nice. My problem is when I Update these...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
31
by: Lag | last post by:
Having a problem updating my database from a web page, through a submission form. Can anyone help? ----THIS IS MY CODE IN update.php----(user, pass, and database are typed in directly, I...
1
by: r2destini | last post by:
Hi Friends, I am new to .Net. So I don't know much. I am facing a problem in updating database through ADO.Net I am creating the dataset and there is no problem in the updation and...
5
by: Brad Baker | last post by:
I'm trying to write a simple asp.net page which updates some data in a SQL database. At the top of the page I have the following code: <%@ Page Language="C#" Debug="true" %> <%@ import...
11
by: SAL | last post by:
Hello, I have a Gridview control (.net 2.0) that I'm having trouble getting the Update button to fire any kind of event or preforming the update. The datatable is based on a join so I don't know...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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 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.