By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,516 Members | 1,133 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,516 IT Pros & Developers. It's quick & easy.

How to read NULL values in SQL using VB .net

P: n/a
Dear folks,
I have a column of data in MS SQL that is being read by my VB .net program. There are a couple of blank/NULL data in those columns. How do I read that data as NULL in VB .net and then make the program skip it. Any pointers would be appreciated.

cheers,

Ranjan

Nov 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi,

Here is a quick example.

Dim strConn As String
Dim conn As OleDb.OleDbConnection
Dim daCustomer As OleDb.OleDbDataAdapter
Dim ds As DataSet

ds = New DataSet()
strConn = "Provider = Microsoft.Jet.OLEDB.4.0;"
strConn &= "Data Source = Northwind.mdb;"

conn = New OleDb.OleDbConnection(strConn)

daCustomer = New OleDb.OleDbDataAdapter("Select * from Customers",
conn)

ds = New DataSet

daCustomer.Fill(ds, "Customers")

For intRow As Integer = 0 To ds.Tables("Customers").Rows.Count - 1
Dim dr As DataRow = ds.Tables("Customers").Rows(intRow)
For x As Integer = 0 To ds.Tables("Customers").Columns.Count - 1
If Not dr.IsNull(x) Then
Debug.WriteLine(dr.Item(x))
Else
Debug.WriteLine("Null")
End If
Next
Next

Ken
--------------------------
"Ranjan as usual" <an*******@discussions.microsoft.com> wrote in message
news:2A**********************************@microsof t.com...
Dear folks,
I have a column of data in MS SQL that is being read by my VB .net
program. There are a couple of blank/NULL data in those columns. How do I
read that data as NULL in VB .net and then make the program skip it. Any
pointers would be appreciated.

cheers,

Ranjan

Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.