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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

[2005] Null Values When Using Databinding

Status
Not open for further replies.

Jonny1409

Technical User
Jan 15, 2006
6
0
0
GB
Hello,

I am using Databinding to bring values from an SQL Server DB through onto my form.

The code is :

Code:
txtName.DataBindings.Clear()
txtName.DataBindings.Add("Text", ds.Tables(0), "Name")

This works well in most cases, but as I have a couple of DateTimePickers on my form aswell, and these don't work so well.

Basically they are fine as long as there isn't a null value in the Database.
If one of the Date fields is null (i.e. Date Of Birth), then I get thrown an error of :

"Object cannot be cast from DBNull to other types."

What is the best way to resolve this ? (Apart from ensure there are no Null fields in the DB, as this isn't possible at the moment.)

I'd be happy for the DateTimePickers to be populated with a default date or be blank, whichever is easier really.

Thanks,
J.
 
Please Ignore This Post - It was made in the wrong forum.

Thanks,
J.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top