Hi guys ,
I am doing a very simple connection with C# and Ms Access and so far every thing goes fine, with me!.I just have a problem on retrieving Null values.the code that I am using to list values of a field in a table is like:

OleDbCommand cmd = new OleDbCommand(sql, cn);
reader = cmd.ExecuteReader();
while (reader.Read()){

as I told you this code works fine and get values of the field but it it return NULL values as well and when I want to list the values in a ListBox they appears like a space in the listbox display as they are a type of data.
Now my question is that how I can stop getting Nulls or not displaying them on the ListBox?!
I appriciate if you give me a good hint on that and also provide me some hints or #Ref to teach me how I can display the query results on a Grid format like a real table(Tabular) in a RichTextbox(or TextBox)?

Thanks again

Recommended Answers

All 6 Replies

My this code:

while (reader.Read())
    if(reader.GetValue(0) != DBNull.Value)
        //or better coding to get value:

This should do it.

Thanks a lot
It works fine now ,
Can you give me a hint how I can find a tutorial or something like this to display the result in tabular view on Txtbox or frame?
thanks again, You are great!

Your are welcome.
What is tabular view?

Well, I mean a tabular view of table like Ms Access with Cells, Rows , and Columns(Header and cells).

You can use the Datagridview which display entire table in the form of row and column

Yep, dataGridView control will be the best option here.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.