ErrorProvider With DataSet and Textboxes

G

Guest

I'm having problems using the errorprovider in VB.NET to automatically
display an error icon next to textboxes bound to the same dataset as the
errorprovider.

The sequence of events is :

Build a dataset containing a single table.
Bind the textboxes on a windows form to the datatable.
Bind the errorprovider control to the same datatable.
Use SetColumnError to create an error condition in the datatable.
Navigate to the row containing the error so that its fields are shown in the
bound textboxes.

At thispoint I would expect the error icon to automatically appear next to
the textbox which is bound to the column containing the error - but nothing
appears.

If I bind the same datatable to a datagrid and repeat the same sequence of
events an error icon is displayed in the grid cell.

The help on this subject suggests that any bound control should
automatically activate the error icon when column errors are present on the
current row as you will see if you follow this link :

http://msdn.microsoft.com/library/d...tasetwithwindowsformserrorprovidercontrol.asp

Help on this would be extremely gratefully received while I still have some
hair left !
(I can supply sample code if this would help)
 
K

Ken Tucker [MVP]

Hi,

This is working for me.

Dim strConn As String

Dim strSQL As String

Dim daEmployees As OleDbDataAdapter

Dim conn As OleDbConnection

strConn = "Provider = Microsoft.Jet.OLEDB.4.0;"

strConn &= "Data Source = Northwind.mdb;"

conn = New OleDbConnection(strConn)



daEmployees = New OleDbDataAdapter("Select * From Employees Order by
LastName, FirstName", conn)

daEmployees.Fill(ds, "Employees")



ds.Tables("Employees").Rows(0).SetColumnError("LastName", "Lazy")

TextBox1.DataBindings.Add("Text", ds.Tables("Employees"), "LastName")

ErrorProvider1.DataSource = ds.Tables("Employees")



Ken

-----------------------

I'm having problems using the errorprovider in VB.NET to automatically
display an error icon next to textboxes bound to the same dataset as the
errorprovider.

The sequence of events is :

Build a dataset containing a single table.
Bind the textboxes on a windows form to the datatable.
Bind the errorprovider control to the same datatable.
Use SetColumnError to create an error condition in the datatable.
Navigate to the row containing the error so that its fields are shown in the
bound textboxes.

At thispoint I would expect the error icon to automatically appear next to
the textbox which is bound to the column containing the error - but nothing
appears.

If I bind the same datatable to a datagrid and repeat the same sequence of
events an error icon is displayed in the grid cell.

The help on this subject suggests that any bound control should
automatically activate the error icon when column errors are present on the
current row as you will see if you follow this link :

http://msdn.microsoft.com/library/d...tasetwithwindowsformserrorprovidercontrol.asp

Help on this would be extremely gratefully received while I still have some
hair left !
(I can supply sample code if this would help)
 
G

Guest

Thanks for that Ken - I now have automatic error icons, although it has not
been implemented the way the help files suggest it should be done !!

What I have found is that for a dataset containing a table called TEST the
following code DOESN'T work for getting automatic error provider icons
(except in datagrids):
ErrorProvider1.DataSource = mSet
ErrorProvider1.DataMember = "TEST"
also
ErrorProvider1.BindToDataAndErrors(mDataSet, "TEST")
does not work (except in datagrids)

but
ErrorProvider1.DataSource = mSet.Tables("TEST")
DOES work.

Conclusion - I'll stick the the way that works !!
Thanks again for your help.
 

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

Top