ASP.NET 2.0 Strongly Typed TableAdapters question with dropdownlist box

Discussion in 'ASP .Net' started by Ted Ngo, Sep 21, 2006.

  1. Ted Ngo

    Ted Ngo Guest

    I create a northwind Strongly Typed TableAdapters dataset,
    the create a query like "select a, b, c, d from employeetable"

    then bind it into the gridview

    dim t as new northwindTableAdapters
    gridview1.datasource = t.getdata()
    gridview1.databind()

    Now I create new query in the TableAdapters dataset
    "select distinct d from the mployeetable"
    I want to bind d value into the dropdownlist box;

    dim t2 as new northwindTableAdapters
    dropdownlist1.datasource = t2.getonlyd()
    dropdownlist1.databind()

    it complie ok, but when I run it I got this error message:
    Failed to enable constraints. One or more rows contain values violating
    non-null, unique, or foreign-key constraints.

    Why?, Please help Thank.
     
    Ted Ngo, Sep 21, 2006
    #1
    1. Advertising

  2. Ted Ngo

    David Wier Guest

    On what line does it break?

    --
    David Wier
    MVP/ASPInsider
    http://aspnet101.com
    http://aspexpress.com


    "Ted Ngo" <> wrote in message
    news:...
    > I create a northwind Strongly Typed TableAdapters dataset,
    > the create a query like "select a, b, c, d from employeetable"
    >
    > then bind it into the gridview
    >
    > dim t as new northwindTableAdapters
    > gridview1.datasource = t.getdata()
    > gridview1.databind()
    >
    > Now I create new query in the TableAdapters dataset
    > "select distinct d from the mployeetable"
    > I want to bind d value into the dropdownlist box;
    >
    > dim t2 as new northwindTableAdapters
    > dropdownlist1.datasource = t2.getonlyd()
    > dropdownlist1.databind()
    >
    > it complie ok, but when I run it I got this error message:
    > Failed to enable constraints. One or more rows contain values violating
    > non-null, unique, or foreign-key constraints.
    >
    > Why?, Please help Thank.
    >
     
    David Wier, Sep 21, 2006
    #2
    1. Advertising

  3. Ted Ngo

    Ted Ngo Guest

    Re: ASP.NET 2.0 Strongly Typed TableAdapters question with dropdownlist box

    I break on this line dropdownlist1.datasource = t2.getonlyd()


    When I try to create the query "Select distinct d from the from
    employeetable" the application also give me this error message too:
    "The new command text returns data with schema different from the
    schema of the main query. Check your query's command text if this is
    not desired."

    Thanks


    David Wier wrote:
    > On what line does it break?
    >
    > --
    > David Wier
    > MVP/ASPInsider
    > http://aspnet101.com
    > http://aspexpress.com
    >
    >
    > "Ted Ngo" <> wrote in message
    > news:...
    > > I create a northwind Strongly Typed TableAdapters dataset,
    > > the create a query like "select a, b, c, d from employeetable"
    > >
    > > then bind it into the gridview
    > >
    > > dim t as new northwindTableAdapters
    > > gridview1.datasource = t.getdata()
    > > gridview1.databind()
    > >
    > > Now I create new query in the TableAdapters dataset
    > > "select distinct d from the mployeetable"
    > > I want to bind d value into the dropdownlist box;
    > >
    > > dim t2 as new northwindTableAdapters
    > > dropdownlist1.datasource = t2.getonlyd()
    > > dropdownlist1.databind()
    > >
    > > it complie ok, but when I run it I got this error message:
    > > Failed to enable constraints. One or more rows contain values violating
    > > non-null, unique, or foreign-key constraints.
    > >
    > > Why?, Please help Thank.
    > >
     
    Ted Ngo, Sep 21, 2006
    #3
  4. Ted Ngo

    David Wier Guest

    Re: ASP.NET 2.0 Strongly Typed TableAdapters question with dropdownlist box

    Go to your TableAdapter and click on 'Preview Data' to see what happens
    directly from the TableAdapter...if the error occurs there, too, then, you
    need to fix it there.

    However, I just noticed something else - usually, when you Dim a
    TableAdapter, it's more specific than what you have - instead of:
    dim t as new northwindTableAdapters
    The XSD, if named 'Northwind', and the TableAdapter named
    EMployeesTableAdapter, it would be more like:
    Dim t As New NorthwindTableAdapters.EmployeesTableAdapter

    --
    David Wier
    MVP/ASPInsider
    http://aspnet101.com
    http://aspexpress.com



    "Ted Ngo" <> wrote in message
    news:...
    > I break on this line dropdownlist1.datasource = t2.getonlyd()
    >
    >
    > When I try to create the query "Select distinct d from the from
    > employeetable" the application also give me this error message too:
    > "The new command text returns data with schema different from the
    > schema of the main query. Check your query's command text if this is
    > not desired."
    >
    > Thanks
    >
    >
    > David Wier wrote:
    > > On what line does it break?
    > >
    > > --
    > > David Wier
    > > MVP/ASPInsider
    > > http://aspnet101.com
    > > http://aspexpress.com
    > >
    > >
    > > "Ted Ngo" <> wrote in message
    > > news:...
    > > > I create a northwind Strongly Typed TableAdapters dataset,
    > > > the create a query like "select a, b, c, d from employeetable"
    > > >
    > > > then bind it into the gridview
    > > >
    > > > dim t as new northwindTableAdapters
    > > > gridview1.datasource = t.getdata()
    > > > gridview1.databind()
    > > >
    > > > Now I create new query in the TableAdapters dataset
    > > > "select distinct d from the mployeetable"
    > > > I want to bind d value into the dropdownlist box;
    > > >
    > > > dim t2 as new northwindTableAdapters
    > > > dropdownlist1.datasource = t2.getonlyd()
    > > > dropdownlist1.databind()
    > > >
    > > > it complie ok, but when I run it I got this error message:
    > > > Failed to enable constraints. One or more rows contain values

    violating
    > > > non-null, unique, or foreign-key constraints.
    > > >
    > > > Why?, Please help Thank.
    > > >

    >
     
    David Wier, Sep 21, 2006
    #4
  5. Ted Ngo

    Ted Ngo Guest

    Re: ASP.NET 2.0 Strongly Typed TableAdapters question with dropdownlist box

    When I ran the "Preview Data" it return the country fine, but
    on the "Preview Data" it show me column = 7 and row = 67.
    Why?
    I do select distinct title only, it should return on column = 1 and row
    = 67.

    Thanks,


    David Wier wrote:
    > Go to your TableAdapter and click on 'Preview Data' to see what happens
    > directly from the TableAdapter...if the error occurs there, too, then, you
    > need to fix it there.
    >
    > However, I just noticed something else - usually, when you Dim a
    > TableAdapter, it's more specific than what you have - instead of:
    > dim t as new northwindTableAdapters
    > The XSD, if named 'Northwind', and the TableAdapter named
    > EMployeesTableAdapter, it would be more like:
    > Dim t As New NorthwindTableAdapters.EmployeesTableAdapter
    >
    > --
    > David Wier
    > MVP/ASPInsider
    > http://aspnet101.com
    > http://aspexpress.com
    >
    >
    >
    > "Ted Ngo" <> wrote in message
    > news:...
    > > I break on this line dropdownlist1.datasource = t2.getonlyd()
    > >
    > >
    > > When I try to create the query "Select distinct d from the from
    > > employeetable" the application also give me this error message too:
    > > "The new command text returns data with schema different from the
    > > schema of the main query. Check your query's command text if this is
    > > not desired."
    > >
    > > Thanks
    > >
    > >
    > > David Wier wrote:
    > > > On what line does it break?
    > > >
    > > > --
    > > > David Wier
    > > > MVP/ASPInsider
    > > > http://aspnet101.com
    > > > http://aspexpress.com
    > > >
    > > >
    > > > "Ted Ngo" <> wrote in message
    > > > news:...
    > > > > I create a northwind Strongly Typed TableAdapters dataset,
    > > > > the create a query like "select a, b, c, d from employeetable"
    > > > >
    > > > > then bind it into the gridview
    > > > >
    > > > > dim t as new northwindTableAdapters
    > > > > gridview1.datasource = t.getdata()
    > > > > gridview1.databind()
    > > > >
    > > > > Now I create new query in the TableAdapters dataset
    > > > > "select distinct d from the mployeetable"
    > > > > I want to bind d value into the dropdownlist box;
    > > > >
    > > > > dim t2 as new northwindTableAdapters
    > > > > dropdownlist1.datasource = t2.getonlyd()
    > > > > dropdownlist1.databind()
    > > > >
    > > > > it complie ok, but when I run it I got this error message:
    > > > > Failed to enable constraints. One or more rows contain values

    > violating
    > > > > non-null, unique, or foreign-key constraints.
    > > > >
    > > > > Why?, Please help Thank.
    > > > >

    > >
     
    Ted Ngo, Sep 21, 2006
    #5
  6. Ted Ngo

    jayeshkitukale

    Joined:
    Jun 20, 2008
    Messages:
    2
    You need to use a different TableAdapter for this new schema.
     
    jayeshkitukale, Jun 20, 2008
    #6
  7. Ted Ngo

    jayeshkitukale

    Joined:
    Jun 20, 2008
    Messages:
    2
    One tableadapter can handle exactly one set of SELECT FIELDSET
     
    jayeshkitukale, Jun 20, 2008
    #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. Narayanan Sankaranarayanan

    Custom Namespace For Strongly Typed DataSet

    Narayanan Sankaranarayanan, Dec 15, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    1,101
    Narayanan Sankaranarayanan
    Dec 15, 2004
  2. Imran

    Strongly Typed dataset

    Imran, Jan 23, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    591
    Richard A. Lowe
    Jan 23, 2004
  3. =?Utf-8?B?U2NvdHRfZnJvbV9DYXJlbWF0aWM=?=

    allow nulls in strongly typed data set asp.net

    =?Utf-8?B?U2NvdHRfZnJvbV9DYXJlbWF0aWM=?=, Jun 14, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    3,588
    =?Utf-8?B?U2NvdHRfZnJvbV9DYXJlbWF0aWM=?=
    Jun 14, 2006
  4. Replies:
    0
    Views:
    364
  5. ThatsIT.net.au

    Strongly typed datasets ASP.NET

    ThatsIT.net.au, Mar 28, 2009, in forum: ASP .Net
    Replies:
    5
    Views:
    2,448
    Mr. Arnold
    Mar 28, 2009
Loading...

Share This Page