asp.net用户登录代码

来源:百度知道 编辑:UC知道 时间:2024/09/18 04:17:13
public DataTable ExecuteSqlRead(string SqlString)
{
SqlCommand SqlCmd = new SqlCommand();
SqlCmd.Connection = new SqlConnection(ConfigurationSettings.AppSettings["ConnString"]);
SqlCmd.CommandText = SqlString;
SqlCmd.CommandType = CommandType.Text;
SqlDataAdapter SqlAd = new SqlDataAdapter(SqlCmd);
DataSet Rs = new DataSet();
SqlAd.Fill(Rs);
return Rs.Tables[0];
} 运行后说 SqlAd.Fill(Rs); 用户代码未处理SqlException
哪位高手帮忙看一下 急 谢谢喽

加个
try
{
SqlCommand SqlCmd = new SqlCommand();
SqlCmd.Connection = new SqlConnection(ConfigurationSettings.AppSettings["ConnString"]);
SqlCmd.CommandText = SqlString;
SqlCmd.CommandType = CommandType.Text;
SqlDataAdapter SqlAd = new SqlDataAdapter(SqlCmd);
DataSet Rs = new DataSet();
SqlAd.Fill(Rs);
return Rs.Tables[0];

}
catch(Exception ex)
{
throw ex;
}