Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ### Problem with Typed Dataset ###

Reply
Thread Tools

### Problem with Typed Dataset ###

 
 
Kiran
Guest
Posts: n/a
 
      07-15-2005
Hi,

I am using typed dataset for Employees Table and found a problem, can anyone tell me what's wrong

Case 1:

Employees Table:
ID: int,Not Null,Idendity, Primary col
Name:varchar(20),Not Null
Type: Varchar(5), Null(Allowed)

When I retrieve data and fill into the typed dataset from the above table(select ID,Name from Employees), Works fine

Case 2:

Employees Table:
ID: int,Not Null,Idendity, Primary col
Name:varchar(20),Not Null
Type: Varchar(5), Not Null,Default Value: ('')

When I retrieve data and fill into the typed dataset from the above table(select ID,Name from Employees), doesn't work

I get a constraint exception in this case bcos Type column is not selected.

But Type column has a default value(''), It should work right?

doesn't works, any Ideas?????

Thanks
Kiran
 
Reply With Quote
 
 
 
 
Rogas69
Guest
Posts: n/a
 
      07-15-2005
what constraint exception? can you specify exact error message? what are relationships in your database?
if you have typed dataset that contains three columns, why are you selecting only two?

peter
 
Reply With Quote
 
 
 
 
Kiran
Guest
Posts: n/a
 
      07-16-2005
Hi,

I need only two columns, that's the reason I am selecting two.

The exception I get is

System.Data.ConstraintException: Failed to enable constraints. One or more
rows contain values violating non-null, unique, or foreign-key constraints.

Thanks
Kiran
"Rogas69" <rogas69@no_spamers.o2.ie> wrote in message news:%...
what constraint exception? can you specify exact error message? what are relationships in your database?
if you have typed dataset that contains three columns, why are you selecting only two?

peter
 
Reply With Quote
 
=?Utf-8?B?Qm9ubmllIEJlcmVudCBbQyMgTVZQXQ==?=
Guest
Posts: n/a
 
      07-16-2005
Kiran,

What's interesting is that the column Default works just fine if you are
programmatically adding Rows to the DataTable, just not when you're using the
DataAdapter.Fill() ... I tried to find some overload of the .Fill() method
that might get around this, but couldn't. Sounds like a bug with the
DataAdapter, but so far I haven't found a way around it.

~~Bonnie

"Kiran" wrote:

> Hi,
>
> I am using typed dataset for Employees Table and found a problem, can anyone tell me what's wrong
>
> Case 1:
>
> Employees Table:
> ID: int,Not Null,Idendity, Primary col
> Name:varchar(20),Not Null
> Type: Varchar(5), Null(Allowed)
>
> When I retrieve data and fill into the typed dataset from the above table(select ID,Name from Employees), Works fine
>
> Case 2:
>
> Employees Table:
> ID: int,Not Null,Idendity, Primary col
> Name:varchar(20),Not Null
> Type: Varchar(5), Not Null,Default Value: ('')
>
> When I retrieve data and fill into the typed dataset from the above table(select ID,Name from Employees), doesn't work
>
> I get a constraint exception in this case bcos Type column is not selected.
>
> But Type column has a default value(''), It should work right?
>
> doesn't works, any Ideas?????
>
> Thanks
> Kiran

 
Reply With Quote
 
Kiran
Guest
Posts: n/a
 
      07-18-2005
Thanks Bonnie

"Bonnie Berent [C# MVP]" <> wrote
in message news:CD38C58B-451F-4F17-BF60-...
> Kiran,
>
> What's interesting is that the column Default works just fine if you are
> programmatically adding Rows to the DataTable, just not when you're using
> the
> DataAdapter.Fill() ... I tried to find some overload of the .Fill() method
> that might get around this, but couldn't. Sounds like a bug with the
> DataAdapter, but so far I haven't found a way around it.
>
> ~~Bonnie
>
> "Kiran" wrote:
>
>> Hi,
>>
>> I am using typed dataset for Employees Table and found a problem, can
>> anyone tell me what's wrong
>>
>> Case 1:
>>
>> Employees Table:
>> ID: int,Not Null,Idendity, Primary col
>> Name:varchar(20),Not Null
>> Type: Varchar(5), Null(Allowed)
>>
>> When I retrieve data and fill into the typed dataset from the above
>> table(select ID,Name from Employees), Works fine
>>
>> Case 2:
>>
>> Employees Table:
>> ID: int,Not Null,Idendity, Primary col
>> Name:varchar(20),Not Null
>> Type: Varchar(5), Not Null,Default Value: ('')
>>
>> When I retrieve data and fill into the typed dataset from the above
>> table(select ID,Name from Employees), doesn't work
>>
>> I get a constraint exception in this case bcos Type column is not
>> selected.
>>
>> But Type column has a default value(''), It should work right?
>>
>> doesn't works, any Ideas?????
>>
>> Thanks
>> Kiran



 
Reply With Quote
 
Rich
Guest
Posts: n/a
 
      07-18-2005
Can you not just add a dummy column to the select statement? The default is "" so

Select Id, Name, '' as Type from Employees

I have not tried this out but if you have not I would give it a whirl.

Rich



"Kiran" <> wrote in message news:...
Hi,

I am using typed dataset for Employees Table and found a problem, can anyone tell me what's wrong

Case 1:

Employees Table:
ID: int,Not Null,Idendity, Primary col
Name:varchar(20),Not Null
Type: Varchar(5), Null(Allowed)

When I retrieve data and fill into the typed dataset from the above table(select ID,Name from Employees), Works fine

Case 2:

Employees Table:
ID: int,Not Null,Idendity, Primary col
Name:varchar(20),Not Null
Type: Varchar(5), Not Null,Default Value: ('')

When I retrieve data and fill into the typed dataset from the above table(select ID,Name from Employees), doesn't work

I get a constraint exception in this case bcos Type column is not selected.

But Type column has a default value(''), It should work right?

doesn't works, any Ideas?????

Thanks
Kiran
 
Reply With Quote
 
Kiran
Guest
Posts: n/a
 
      07-19-2005
I give it a try, thanks
"Rich" <> wrote in message news:...
Can you not just add a dummy column to the select statement? The default is "" so

Select Id, Name, '' as Type from Employees

I have not tried this out but if you have not I would give it a whirl.

Rich



"Kiran" <> wrote in message news:...
Hi,

I am using typed dataset for Employees Table and found a problem, can anyone tell me what's wrong

Case 1:

Employees Table:
ID: int,Not Null,Idendity, Primary col
Name:varchar(20),Not Null
Type: Varchar(5), Null(Allowed)

When I retrieve data and fill into the typed dataset from the above table(select ID,Name from Employees), Works fine

Case 2:

Employees Table:
ID: int,Not Null,Idendity, Primary col
Name:varchar(20),Not Null
Type: Varchar(5), Not Null,Default Value: ('')

When I retrieve data and fill into the typed dataset from the above table(select ID,Name from Employees), doesn't work

I get a constraint exception in this case bcos Type column is not selected.

But Type column has a default value(''), It should work right?

doesn't works, any Ideas?????

Thanks
Kiran
 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Difference Between Typed Dataset and Untyped Dataset thomson ASP .Net 2 01-19-2005 08:16 AM
Converting a generic Dataset to a typed dataset William Gower ASP .Net 2 07-26-2004 10:14 PM
copying a datatable content from an untyped dataset into a table which is inside a typed dataset Nedu N ASP .Net 2 10-31-2003 01:05 PM
Ccopying a datatable content from an untyped dataset into a table which is inside a typed dataset Nedu N ASP .Net 2 10-31-2003 02:42 AM
Ccopying a datatable content from an untyped dataset into a table which is inside a typed dataset Nedu N ASP .Net 1 10-31-2003 02:39 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57