Try this:
try
{
DataTable k = new System.Data.DataTable();
string str = "Data Source=C:\\Documents and Settings\\almas\\Desktop\\BazarKhodro\\khodro.sdf";
Qconnection.ConnectionString = str;
Qcommand.Connection = Qconnection;
string commandText = "select name,lname,phone,mobile,address from moshtari where name=@name and lname=@lname";
Qcommand.Parameters.AddWithValue("@name", textBox3.Text);
Qcommand.Parameters.AddWithValue("@lname", textBox4.Text);
Qcommand.CommandText = commandText;
Qcommand.CommandType = CommandType.Text;
SqlCeDataAdapter a = new SqlCeDataAdapter();
a.SelectCommand = Qcommand;
a.Fill(k);
BindingSource bSource = new BindingSource();
bSource.DataSource = k;
dataGridView1.DataSource = bSource;
Qconnection.Close();
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}