### Problem with Typed Dataset ###

Discussion in 'ASP .Net' started by Kiran, Jul 15, 2005.

  1. Kiran

    Kiran Guest

    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
     
    Kiran, Jul 15, 2005
    #1
    1. Advertising

  2. Kiran

    Rogas69 Guest

    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
     
    Rogas69, Jul 15, 2005
    #2
    1. Advertising

  3. Kiran

    Kiran Guest

    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
     
    Kiran, Jul 16, 2005
    #3
  4. 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
     
    =?Utf-8?B?Qm9ubmllIEJlcmVudCBbQyMgTVZQXQ==?=, Jul 16, 2005
    #4
  5. Kiran

    Kiran Guest

    Thanks Bonnie

    "Bonnie Berent [C# MVP]" <> wrote
    in message news:...
    > 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
     
    Kiran, Jul 18, 2005
    #5
  6. Kiran

    Rich Guest

    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
     
    Rich, Jul 18, 2005
    #6
  7. Kiran

    Kiran Guest

    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
     
    Kiran, Jul 19, 2005
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nedu N
    Replies:
    1
    Views:
    1,824
    Chris Taylor
    Oct 31, 2003
  2. Nedu N
    Replies:
    2
    Views:
    2,190
  3. William Gower
    Replies:
    2
    Views:
    4,177
    Brian Baker [MVP]
    Jul 26, 2004
  4. thomson
    Replies:
    2
    Views:
    14,853
    Eliyahu Goldin
    Jan 19, 2005
  5. Nedu N
    Replies:
    2
    Views:
    230
    Jacob Yang [MSFT]
    Oct 31, 2003
Loading...

Share This Page