未处理的“System.Data.OleDb.OleDbException”类型的异常出现在 system.data.dll 中。

来源:百度知道 编辑:UC知道 时间:2024/05/13 15:20:38
我的.net程序提示:未处理的“System.Data.OleDb.OleDbException”类型的异常出现在 system.data.dll 中。请问是什么原因?
代码是:// 判断某用户是否存在
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

用户代码未处理 System.NullReferenceException 未处理 System.Data.SqlClient.SqlException 未处理的“System.Data.OleDb.OleDbException”类型的异常出现在 system.data.dll 中。 未处理的“System.ArgumentException”类型的异常出现在 system.windows.forms.dll 中。 未处理的“System.Data.SqlClient.SqlException”类型的异常出现在 system.data.dll 中。 未处理的“System.StackOverflowException”类型的异常出现在 system.windows.forms.dll 中。 未处理的“System.NullReferenceException”类型的异常出现在 system.windows.forms.dll 中。 未处理的“System.NullReferenceException”类型的异常出现在 system.data.dll 中。 未处理的“System.OutOfMemoryException”类型的异常出现在 system.windows.forms.dll 中。 金山毒霸扫描到的病毒System Volume Information\_restore{F3E Win32说是全部未处理