ASP.NET 2.0 Strongly Typed TableAdapters question with dropdownlist box

T

Ted Ngo

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.
 
T

Ted Ngo

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
 
D

David Wier

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
 
T

Ted Ngo

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,
 

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

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top