Look at this!
Can sombody tell me how to do this...
I filled a data table like this
DataTable dt=new DataTable();
dt=ds.Tables[0];
And then I assign this dt to DataGridView in C#.Net 2005 like this,
DataGridView1.DataSource=dt;
It was successfull but the empty values come from Database shows on the grid as it is and I want to filter them. I used some techniques like gatting the values to a DataRow and then fill DataGridView by that DataRow. But It was no use. Can anyone tell me how to do this? Thank you very much!
nishan
[570 byte] By [
nishandj] at [2007-11-20 1:07:27]

# 1 Re: Look at this!
open a new connection and a datareader
make a new datatable with three columns Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\attendence.mdb;Persist Security Info=False")
Dim cmd As New OleDbCommand("SELECT * FROM student", conn)
Dim dt As New DataTable
dt.Columns.Add("RNo", GetType(Integer))
dt.Columns.Add("Name", GetType(String))
dt.Columns.Add("SessionNo", GetType(Integer))
Dim reader As OleDbDataReader
conn.Open()
reader = cmd.ExecuteReader()Loop and read and add row into datatable if sessno is not equal to 0
While (reader.Read())
If reader.GetValue(2) <> 0 Then 'don't show null session
Dim r As DataRow = dt.NewRow
r(0) = reader.GetValue(0)
r(1) = reader.GetValue(1)
r(2) = reader.GetValue(2)
dt.Rows.Add(r)
End If
End While
conn.Close() Me.DataGridView1.DataSource = dt
# 2 Re: Look at this!
noooooooo, you put the checking bit in your query!
SELECT * FROM student
make it:
SELECT * FROM student WHERE xyz IS NOT NULL
cjard at 2007-11-10 3:31:20 >
