public Boolean ExecSql(string sQueryString)
{
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["conStr"]);
SqlCommand command1 = new SqlCommand(sQueryString, con);
command1.Connection.Open();
command1.ExecuteNonQuery();
command1.Connection.Close();
return true;
}
然后我在一个buttion的OnClick事件中写到
{
bc.ExecSql("Update News SET Title=" + "'" + TextBox1.Text + "'");
}
运行后没有发生改变,页面就只是刷新了一下而已.这是怎么回事?
{
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["conStr"]);
SqlCommand command1 = new SqlCommand(sQueryString, con);
command1.Connection.Open();
command1.ExecuteNonQuery();
command1.Connection.Close();
return true;
}
然后我在一个buttion的OnClick事件中写到
{
bc.ExecSql("Update News SET Title=" + "'" + TextBox1.Text + "'");
}
运行后没有发生改变,页面就只是刷新了一下而已.这是怎么回事?
检查下
呵呵;楼主还是改改吧
{
try
{
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["conStr"]);
SqlCommand command1 = new SqlCommand(sQueryString, con);
command1.Connection.Open();
command1.ExecuteNonQuery();
command1.Connection.Close();
}catch(Exception ex)
{
Response.Write(ex.Message)
}
return true;
}用try...catch试下