public DataTable Search(int m)
{
DataTable k = new System.Data.DataTable();
try
{
string str = "Data Source=C:\\Documents and Settings\\almas\\Desktop\\BazarKhodro\\khodro.sdf";
Qconnection.ConnectionString = str;
Qcommand.Connection = Qconnection;
string cond="";
string commandText = "SELECT foroosh.date, moshtari.name, moshtari.lname,moshtari.mobile, foroosh.type, foroosh.model, foroosh.tip, foroosh.karkard,foroosh.color, foroosh.sales, foroosh.badane,foroosh.price,foroosh.mojood,foroosh.comment FROM foroosh INNER JOIN moshtari ON foroosh.mid = moshtari.id where foroosh.parvande=@par "+cond ;
Qcommand.Parameters.AddWithValue("@type", dataGridView2.Rows[m].Cells[0].Value.ToString());
Qcommand.Parameters.AddWithValue("@modelfrom", dataGridView2.Rows[m].Cells[1].Value.ToString());
Qcommand.Parameters.AddWithValue("@modelto", dataGridView2.Rows[m].Cells[2].Value.ToString());
Qcommand.Parameters.AddWithValue("@tip", dataGridView2.Rows[m].Cells[3].Value.ToString());
Qcommand.Parameters.AddWithValue("@karkardfrom", dataGridView2.Rows[m].Cells[4].Value.ToString());
Qcommand.Parameters.AddWithValue("@karkardto", dataGridView2.Rows[m].Cells[5].Value.ToString());
Qcommand.Parameters.AddWithValue("@color", dataGridView2.Rows[m].Cells[6].Value.ToString());
Qcommand.Parameters.AddWithValue("@pricefrom", dataGridView2.Rows[m].Cells[7].Value.ToString());
Qcommand.Parameters.AddWithValue("@priceto", dataGridView2.Rows[m].Cells[8].Value.ToString());
Qcommand.Parameters.AddWithValue("@par", "faal");
Qcommand.CommandText = commandText;
Qcommand.CommandType = CommandType.Text;
SqlCeDataAdapter a = new SqlCeDataAdapter();
a.SelectCommand = Qcommand;
a.Fill(k);
Qconnection.Open();
Qconnection.Close();
return k;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
return k;
}
}
i want to read from data base and if value of column mojood of table is true the chech box column of gridview checked