Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data Binding

Status
Not open for further replies.

vonehle

Programmer
May 16, 2006
35
US
After all the fun yesterday...

Now I'm having a problem with binding a blank field.

For instance,

pbndTemp = New Binding("text", drCurrent, "fouls_home")
txtHomeFouls.DataBindings.Add(pbndTemp)

If "fouls_home" is blank, I get an error saying "Cannot get field because it is DBNULL". I tried changing the default value in the database to 0, but it didn't help.
 
In the SQL that pulls the data from the database, you can make any numeric Null values into 0 like this:

Select IsNull(FieldName, 0) as FieldName From TableName

This will return 0 in any records where the field is null. For character fields, you can return a blank like this:

Select IsNull(FieldName, '') as FieldName From TableName

this way there will be no null values in your datatable.

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day! Ye has a choice: talk like a pira
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top