Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   ASP.NET 2.0 Strongly Typed TableAdapters question with dropdownlist box (http://www.velocityreviews.com/forums/t372340-asp-net-2-0-strongly-typed-tableadapters-question-with-dropdownlist-box.html)

Ted Ngo 09-21-2006 03:47 PM

ASP.NET 2.0 Strongly Typed TableAdapters question with dropdownlist box
 
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 09-21-2006 04:08 PM

Re: ASP.NET 2.0 Strongly Typed TableAdapters question with dropdownlist box
 
On what line does it break?

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


"Ted Ngo" <ntuyen01@yahoo.com> wrote in message
news:1158853649.328183.179240@d34g2000cwd.googlegr 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.
>




Ted Ngo 09-21-2006 04:17 PM

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" <ntuyen01@yahoo.com> wrote in message
> news:1158853649.328183.179240@d34g2000cwd.googlegr 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.
> >



David Wier 09-21-2006 07:12 PM

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" <ntuyen01@yahoo.com> wrote in message
news:1158855440.899414.45980@d34g2000cwd.googlegro 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" <ntuyen01@yahoo.com> wrote in message
> > news:1158853649.328183.179240@d34g2000cwd.googlegr 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.
> > >

>




Ted Ngo 09-21-2006 07:38 PM

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" <ntuyen01@yahoo.com> wrote in message
> news:1158855440.899414.45980@d34g2000cwd.googlegro 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" <ntuyen01@yahoo.com> wrote in message
> > > news:1158853649.328183.179240@d34g2000cwd.googlegr 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.
> > > >

> >



jayeshkitukale 06-20-2008 12:34 PM

You need to use a different TableAdapter for this new schema.

jayeshkitukale 06-20-2008 12:34 PM

One tableadapter can handle exactly one set of SELECT FIELDSET


All times are GMT. The time now is 08:46 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.