PDA

View Full Version : آموزش: اشكال در جستجو و ارسال جواب به dataGridView



jeivid
چهارشنبه 10 فروردین 1390, 17:55 عصر
با سلام دوستان من مي خوام از بانك اطلاعاتي كلماتي را جستجو كنم و توي dataGridView قرار بدم ولي نميشه مي تونين بگين مشكلش كد كجاست

private void txtsearch_KeyPress(object sender, KeyPressEventArgs e)
{
DataTable dt = new DataTable();
sendmail sm = new sendmail();

if (rbother.Checked == true)
{
dt = sm.searchother(txtsearch.Text);
dataGridView1.DataSource = dt;
}


}

و اينم كد اس كيو ال ش هستش


public DataTable searchother(string other)
{
string sql = "select * from sendmail where Sother like '%N{0}%'";
sql = string.Format(sql, other);
DataTable dt = new DataTable();
db.Connect();
dt = db.Select(sql);
db.Disconnect();
return dt;
}

shadi khanum
پنج شنبه 11 فروردین 1390, 00:52 صبح
اون دستور Sql که نوشتین جای N اشتباهه. باید قبل از ' باشه یعنی این
string sql = "select * from sendmail where Sother like N'%{0}%'";