Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP.NET 2.0 Strongly Typed TableAdapters question with dropdownlist box

Reply
Thread Tools

ASP.NET 2.0 Strongly Typed TableAdapters question with dropdownlist box

 
 
Ted Ngo
Guest
Posts: n/a
 
      09-21-2006
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.

 
Reply With Quote
 
 
 
 
David Wier
Guest
Posts: n/a
 
      09-21-2006
On what line does it break?

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


"Ted Ngo" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> 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.
>



 
Reply With Quote
 
 
 
 
Ted Ngo
Guest
Posts: n/a
 
      09-21-2006
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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) oups.com...
> > 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.
> >


 
Reply With Quote
 
David Wier
Guest
Posts: n/a
 
      09-21-2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> 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" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed) oups.com...
> > > 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.
> > >

>



 
Reply With Quote
 
Ted Ngo
Guest
Posts: n/a
 
      09-21-2006
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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) ups.com...
> > 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" <(E-Mail Removed)> wrote in message
> > > news:(E-Mail Removed) oups.com...
> > > > 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.
> > > >

> >


 
Reply With Quote
 
jayeshkitukale jayeshkitukale is offline
Junior Member
Join Date: Jun 2008
Posts: 2
 
      06-20-2008
You need to use a different TableAdapter for this new schema.
 
Reply With Quote
 
jayeshkitukale jayeshkitukale is offline
Junior Member
Join Date: Jun 2008
Posts: 2
 
      06-20-2008
One tableadapter can handle exactly one set of SELECT FIELDSET
 
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
ASP.NET 2.0 Strongly Typed TableAdapters question rswafford@gmail.com ASP .Net 0 07-19-2006 09:46 PM
Custom Namespace For Strongly Typed DataSet Narayanan Sankaranarayanan ASP .Net 0 12-15-2004 01:28 AM
Help with creating strongly typed DataSet =?Utf-8?B?QW5kcmUgUmFuaWVyaQ==?= ASP .Net 1 04-19-2004 12:42 AM
Strongly typed datasets and XML Big D ASP .Net 1 02-17-2004 11:32 PM
Strongly Typed dataset Imran ASP .Net 1 01-23-2004 07:42 AM



Advertisments