PC Review


Reply
Thread Tools Rate Thread

Column names and typed dataset

 
 
=?Utf-8?B?QW5IdW5k?=
Guest
Posts: n/a
 
      21st Nov 2005
I came across one thing/problem regarding typed datasets in the case where
the column name has two words or has a dash in between the words in the
column name like:

"E-mail" or "Expiry date"

In the select statment I use [E-mail] and [Expiry date] which works fine,
but the problem is that the

OleDbCommandBuilder(adapter)

does not build correct update statements and I get an error ("Syntax error
in UPDATE statement") when trying to update a row with "E-mail" or "Expiry
date"

Other colums with a single word column name works just fine.

Any hints would be very much appreciated.

Thanks..

Please see code sample below (not complete with all details, just to get an
idea):


string SqlString = "SELECT CustomerID, Firstname, [E-mail], [Expiry date]
FROM Customers";

// Create new dataset
CustomerDataset customerDataset = new CustomerDataset();

// Get customers
db.Execute(customerDataset, "Customers");

// Select row 1 (could be any other row)
CustomerDataset.CustomerRow row = (CustomerDataset.CustomerRow)

customerDataset.Customer.Rows[1];
// Change some fields
row.Firstname = "ZZ Top";
row._E_mail = (E-Mail Removed);

// Then update data base with the changes
connection.ConnectionString = ConnectionString;
command.CommandText = SqlString;

// Auto generate update statements
OleDbCommandBuilder up = new OleDbCommandBuilder(adapter);

// UPDATE FAILS WITH "Syntax error in UPDATE statement"
adapter.Update(ds, tableName);

NOTE: everything works just fine if the column names are one word like
"Email", "Expirydate" etc.
 
Reply With Quote
 
 
 
 
Bart Mermuys
Guest
Posts: n/a
 
      22nd Nov 2005
Hi,

"AnHund" <(E-Mail Removed)> wrote in message
news:02541C39-C3EC-4982-99FC-(E-Mail Removed)...
>I came across one thing/problem regarding typed datasets in the case where
> the column name has two words or has a dash in between the words in the
> column name like:
>
> "E-mail" or "Expiry date"
>
> In the select statment I use [E-mail] and [Expiry date] which works fine,
> but the problem is that the
>
> OleDbCommandBuilder(adapter)
>
> does not build correct update statements and I get an error ("Syntax error
> in UPDATE statement") when trying to update a row with "E-mail" or "Expiry
> date"
>
> Other colums with a single word column name works just fine.
>
> Any hints would be very much appreciated.
>
> Thanks..
>
> Please see code sample below (not complete with all details, just to get
> an
> idea):
>
>
> string SqlString = "SELECT CustomerID, Firstname, [E-mail], [Expiry date]
> FROM Customers";
>
> // Create new dataset
> CustomerDataset customerDataset = new CustomerDataset();
>
> // Get customers
> db.Execute(customerDataset, "Customers");
>
> // Select row 1 (could be any other row)
> CustomerDataset.CustomerRow row = (CustomerDataset.CustomerRow)
>
> customerDataset.Customer.Rows[1];
> // Change some fields
> row.Firstname = "ZZ Top";
> row._E_mail = (E-Mail Removed);
>
> // Then update data base with the changes
> connection.ConnectionString = ConnectionString;
> command.CommandText = SqlString;
>
> // Auto generate update statements
> OleDbCommandBuilder up = new OleDbCommandBuilder(adapter);


Try to set:
up.QuotePrefix = "[";
up.QuoteSuffix = "]";

before updating.

HTH,
Greetings


>
> // UPDATE FAILS WITH "Syntax error in UPDATE statement"
> adapter.Update(ds, tableName);
>
> NOTE: everything works just fine if the column names are one word like
> "Email", "Expirydate" etc.



 
Reply With Quote
 
luxspes
Guest
Posts: n/a
 
      22nd Nov 2005
AnHund wrote:
> I came across one thing/problem regarding typed datasets in the case where
> the column name has two words or has a dash in between the words in the
> column name like:
>
> "E-mail" or "Expiry date"
>
> In the select statment I use [E-mail] and [Expiry date] which works fine,
> but the problem is that the
>
> OleDbCommandBuilder(adapter)
>
> does not build correct update statements and I get an error ("Syntax error
> in UPDATE statement") when trying to update a row with "E-mail" or "Expiry
> date"

If you like the idea of having the SQL automatically generated for you
maybe you should take a look at http://www.nhibernate.org



>
> Other colums with a single word column name works just fine.
>
> Any hints would be very much appreciated.
>
> Thanks..
>
> Please see code sample below (not complete with all details, just to get an
> idea):
>
>
> string SqlString = "SELECT CustomerID, Firstname, [E-mail], [Expiry date]
> FROM Customers";
>
> // Create new dataset
> CustomerDataset customerDataset = new CustomerDataset();
>
> // Get customers
> db.Execute(customerDataset, "Customers");
>
> // Select row 1 (could be any other row)
> CustomerDataset.CustomerRow row = (CustomerDataset.CustomerRow)
>
> customerDataset.Customer.Rows[1];
> // Change some fields
> row.Firstname = "ZZ Top";
> row._E_mail = (E-Mail Removed);
>
> // Then update data base with the changes
> connection.ConnectionString = ConnectionString;
> command.CommandText = SqlString;
>
> // Auto generate update statements
> OleDbCommandBuilder up = new OleDbCommandBuilder(adapter);
>
> // UPDATE FAILS WITH "Syntax error in UPDATE statement"
> adapter.Update(ds, tableName);
>
> NOTE: everything works just fine if the column names are one word like
> "Email", "Expirydate" etc.

 
Reply With Quote
 
=?Utf-8?B?QW5IdW5k?=
Guest
Posts: n/a
 
      22nd Nov 2005
Thanks Bart,

Your solution to the problem just works perfectly.

Br. AnHund

"Bart Mermuys" wrote:

> Hi,
>
> "AnHund" <(E-Mail Removed)> wrote in message
> news:02541C39-C3EC-4982-99FC-(E-Mail Removed)...
> >I came across one thing/problem regarding typed datasets in the case where
> > the column name has two words or has a dash in between the words in the
> > column name like:
> >
> > "E-mail" or "Expiry date"
> >
> > In the select statment I use [E-mail] and [Expiry date] which works fine,
> > but the problem is that the
> >
> > OleDbCommandBuilder(adapter)
> >
> > does not build correct update statements and I get an error ("Syntax error
> > in UPDATE statement") when trying to update a row with "E-mail" or "Expiry
> > date"
> >
> > Other colums with a single word column name works just fine.
> >
> > Any hints would be very much appreciated.
> >
> > Thanks..
> >
> > Please see code sample below (not complete with all details, just to get
> > an
> > idea):
> >
> >
> > string SqlString = "SELECT CustomerID, Firstname, [E-mail], [Expiry date]
> > FROM Customers";
> >
> > // Create new dataset
> > CustomerDataset customerDataset = new CustomerDataset();
> >
> > // Get customers
> > db.Execute(customerDataset, "Customers");
> >
> > // Select row 1 (could be any other row)
> > CustomerDataset.CustomerRow row = (CustomerDataset.CustomerRow)
> >
> > customerDataset.Customer.Rows[1];
> > // Change some fields
> > row.Firstname = "ZZ Top";
> > row._E_mail = (E-Mail Removed);
> >
> > // Then update data base with the changes
> > connection.ConnectionString = ConnectionString;
> > command.CommandText = SqlString;
> >
> > // Auto generate update statements
> > OleDbCommandBuilder up = new OleDbCommandBuilder(adapter);

>
> Try to set:
> up.QuotePrefix = "[";
> up.QuoteSuffix = "]";
>
> before updating.
>
> HTH,
> Greetings
>
>
> >
> > // UPDATE FAILS WITH "Syntax error in UPDATE statement"
> > adapter.Update(ds, tableName);
> >
> > NOTE: everything works just fine if the column names are one word like
> > "Email", "Expirydate" etc.

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Typed Dataset Column Assignment Miro Microsoft VB .NET 1 12th Sep 2008 12:42 AM
column names in a strongly typed dataset =?Utf-8?B?U2VyZ2V5IFp1eWV2?= Microsoft ADO .NET 0 21st Feb 2006 04:20 PM
column names in a strongly typed dataset =?Utf-8?B?U2VyZ2V5IFp1eWV2?= Microsoft ADO .NET 0 17th Feb 2006 05:10 PM
Column names typed dataset =?Utf-8?B?bW9ndWxz?= Microsoft ADO .NET 3 12th Jan 2005 10:47 AM
Typed DataSet names - length restriction Eva Lidji Microsoft ADO .NET 0 11th May 2004 03:52 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:42 AM.