### Problem with Typed Dataset ###

K

Kiran

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
 
R

Rogas69

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
 
K

Kiran

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
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
 
G

Guest

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
 
K

Kiran

Thanks Bonnie

Bonnie Berent said:
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
 
R

Rich

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



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
 
K

Kiran

I give it a try, thanks
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



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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top