Data Question

G

Guest

When I tried to retrieve the data from SQL Server database and assign it to a field, it generates an error since the data in SQL Server is "NULL" how am i able to solve that problem?
thanks,

Ed

Source=datasourcename;Database=databasename;User ID=;Password=;")
Conn.open()
myadapter=new OleDbDataAdapter("Select lastname from testtable where ssn=123121234;",conn)
myadapter.Fill(mydataset,"test")
txtlastname.text=mydataset.tables("test").rows(0).Item("lastname") ' Error Occurs here since LastName in SQL Server is NULL
 
W

William \(Bill\) Vaughn

I suggest you come to my day-long workshop in Orlando in September. ;)
Test for the Null value using

if myData is DBNull.Value then...

or

if ds.Tables(0).rows(0).isnull(0) then...

This is discussed in my book.

hth


--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

Ed said:
When I tried to retrieve the data from SQL Server database and assign it
to a field, it generates an error since the data in SQL Server is "NULL"
how am i able to solve that problem?
thanks,

Ed

Source=datasourcename;Database=databasename;User ID=;Password=;")
Conn.open()
myadapter=new OleDbDataAdapter("Select lastname from testtable where ssn=123121234;",conn)
myadapter.Fill(mydataset,"test")
txtlastname.text=mydataset.tables("test").rows(0).Item("lastname") ' Error
Occurs here since LastName in SQL Server is NULL
 

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