数据库连接问题

时间:2012-02-21 19:43:00

标签: database

在本节中,我收到错误

SqlConnection conn = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True");

try
{
    SqlCommand cmd = new SqlCommand("delete from sug where IDbro='" + ime + "'and AtributValue='+atr+' and [+/-]='+rat+' ", conn);
    conn.Open();
    cmd.ExecuteNonQuery();
}
catch (SqlException ex)
{
}
finally
{
     conn.Close();
}
GridView2.DataBind();
promenaP();
}

我遇到数据库删除错误异常

的问题

1 个答案:

答案 0 :(得分:0)

试试这个

SqlCommand cmd = new SqlCommand("delete from sug where IDbro='" + ime + "'and AtributValue='"+atr+"' and [+/-]='"+rat+"' ", conn);

添加“”

我有类似的问题编程android sqlite ...