//{"“TestSecond.Base”的类型初始值设定项引发异常。"}???????????
大家遇到过这样的错误提示吗?
public class Base
{
private static string conn =System.Configuration.ConfigurationSettings.AppSettings[ "ConnectionString "];
private static DB db = new DB(conn);
public static bool Login(string uname,string upwd)
{
string sql= "select * from LoginUser where uid= ' "+ uname + " ' and upwd= ' "+ upwd + " ' ";
string str=(string)db.CmdExcuteScalar(sql);
if(str==null)
{
return false ;
}
return true;
}
}
--------------------------------------------
public class DB
{
private string mConnString = " ";
public DB(string ConnString)
{
mConnString = ConnString;
}
public object CmdExcuteScalar(string sql)
{
object ret = null;
SqlConnection con = new SqlConnection(mConnString);
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
con.Open();
ret = cmd.ExecuteScalar();
cmd.Dispose();
con.Close();
return ret;