Click to See Complete Forum and Search --> : how to check for null in a db field


pgugel
June 17th, 2003, 09:15 PM
I'm trying to modify an existing row of a database by selecting a name from a drop down list. The selected item's value was set to the id in the database. The problem I'm having is after the dim row statement. Here's my code:

Dim row As dsContacts.ContactsRow
row = ??????
row.ContactID = drpContacts.SelectedItem.Value

and here's the error generated from the last line above:

"Object reference not set to an instance of an object"

Does anyone know the proper initialization? Is there a way to just reference the row by id or do I have to use a select statement with "where id = 'x' " ?


-found the answer, have another question-

The initialization statement I was looking for is as follows:

row = dsContacts.Contacts.FindByContactID_(drpContacts.SelectedItem.Value)

Now that I have the correct row, I need to be able to check if certain fields are null before trying to assign their values to controls on my web form. How do I do this?

Oh yeah, I also have a couple drop-down lists which need to be set so they display the value from the corresponding field in the db. Since they don't have a text field does anyone have a good solution for setting them?

bigal1
June 19th, 2003, 11:41 AM
try the function IsDBNull to check

HTH