未处理的“System.Data.OleDb.OleDbException”类型的异常出现在 system.data.dll 中。
来源:百度知道 编辑:UC知道 时间:2024/05/13 15:20:38
代码是:// 判断某用户是否存在
public bool IsUserExist(string UserName)
{
string sql = "select * from Project where UserName=" + "'" + UserName.Trim() + "'";
OleDbConnection cn = new OleDbConnection(ConnectionString);
OleDbDataAdapter da = new OleDbDataAdapter(sql, cn);
DataSet ds = new DataSet();
da.Fill(ds);
if (ds.Tables[0].Rows.Count != 0)
{
return true;
}
else
{
return false;
}
}
问题出现在:da.Fill(ds);
这个是我写的。是连SQL 的不过没有关系。你可以参考一下的。。
public static bool Rt_if_company_name(string company_name,string username)
{
if(username=="" || company_name=="")
return false;
SqlConnection Conn=new SqlConnection(sharecode.Cconn);
Conn.Open();
string sql="SELECT TOP 1 * FROM lyp_up WHERE (company_name = '"+company_name+"') AND (member_name = '"+username+"')";
SqlCommand sqlcmd=new SqlCommand(sql,Conn);
SqlDataReader sqlrdr=sqlcmd.ExecuteReader();
try
{
if(sqlrdr.Read())
{
return true;
}
else
{
return false;
}
}
catch(Exception ex)
{
System.Web.HttpContext.Current.Response.Write("<script language=javascript>");
System.Web.HttpContext.Current.Response.Write("alert('执行错误:"+ex.Message+"');window.histor