Cannot fill my tableadapter

johncassell

Well-known member
Joined
Jun 10, 2007
Messages
120
Location
Redcar, England
Programming Experience
Beginner
Hi there,

could someone help with this please..

I am trying to fill my table adapter but it is coming up with the error below..

I am using an SQL Express 2005 Server and currently only have one table - 'General_Job_Data'.

There is about 23 Columns in this table and of the 3 rows in there, only the first column - job number (Primary Key) column has any data in it. (I removed all other data and allowed NULLS so I could try to locate the problem but it didn't help.

Hope someone can point me in the right direction.

Appreciate any replies at all.

John
 

Attachments

  • constraintexcepetion.JPG
    constraintexcepetion.JPG
    27.7 KB · Views: 25
I have turned off constraints now

VB.NET:
Me.RedcarFirewalkDatabaseDataSet.EnforceConstraints = False

and the info loads ok.

Is this an OK way to do it or should I not be avoiding it like that?

John
 
easy problem to solve (he says :D )

I removed all other data and allowed NULLS so I could try to locate the problem but it didn't help

Example

You create a DataTable from an SQL database. The table columns are ID (no NULLs), Forename (no NULLs), Surname (NULLs)

Your dataTable is then created and stored in your dataset.

You then go back to your SQL database and allow NULLs in Forename.

Run your app, leave forename blank but you get the constraintException error? huh? How come?

Your dataTable DOES NOT automatically update any changes made to your backend database. - I.E. dataType, max field length, nulls allowed etc.

You must right click your dataTable and "configure", and click through the wizard again. This then updates your dataTable to the settings from your data source.


----

However, some people forget to do it at database level and make the change in the dataTable (click the column, and in the properties panel to the right, AllowDBNull=True)

Remember, the dataTable and dataSource must match!
 
I am trying to fill my table adapter

You dont fill tableadapters. TableAdapters fill DataTables. Saying "fill my TableAdapter" is like saying "fill my Bath Tap" rather than "fill my Bath"


but it is coming up with the error below..

I wrote a DLL for Arg81 a while ago, called Nitpick. It finds errors in datasets. You can try downloading it and using it like:

VB.NET:
Try
  ta.Fill(myDataSet) 'or datatable
Catch ex as ConstraintException
  Dim sb as New StringBuilder 
  Nitpick.Datasets.WhatsWrong(myDataSet, sb)
End Try

Your stringbuilder will be filled with stuff like:

"In table WOOLLY_STUFF, row 864, column BAA_BAA is constrained to be unique, value 'black sheep' is already present"
 
Actually, here is the zip, for ease of finding (its only 3kilobytes)

Dont forget to "Add Reference" to it..
 

Attachments

  • Nitpick.zip
    2.7 KB · Views: 11
Hi all,

many thanks thanks for your input

You dont fill tableadapters. TableAdapters fill DataTables. Saying "fill my TableAdapter" is like saying "fill my Bath Tap" rather than "fill my Bath"

I appreciate this sort of comment, at the moment I am just coming to terms with what everything means and this helps a lot.

Arg81: Yes I was making the error of making changes to my database and not re-configuring them. I now know to do this so thanks very much for that.

Hopefully things will run a bit smoother now.

Just wish I could start helping other people with their problems but unfortunately I am miles away from that yet!!

Regards

John
 
To be honest, that catches everyone out. There was a few posts about a month ago where people were making changes to their DB and wondering why the DataTable wasn't reflecting this changes.

On a good note, I was in your position about 1 1/2 years ago. Was completely new to programming, never done any, and had to create an application which changed the way our company's sales & tech departments interacted o_O

This website helped me no end, which is why I still use and input on it today. OK I'm not a master of VB.net - there's a lot I don't know about that, but in terms of ADO.net, Data Access, Databases, and everything that goes with that, I think I've learnt enough to help others out :D
 
Back
Top