System.TypeInitializationException:“ Webservice.Helper.SqlHelper”,System.NullReferenceException

时间:2019-10-10 06:37:16

标签: sql asp.net winforms

配置是否无法从数据库获取数据?

那服务器启动调试失败的原因是什么?我已经检查了很长时间,希望您能救我

public static string sqlServierDBConnectString = ConfigurationManager.ConnectionStrings["datazzj"].ConnectionString;

除了报告错误的地方,还有这个地方:

    public string Login_GetUserID(string username,string pwd){
        string sqlText = @"SELECT UserId FROM [User_Shaoxie] WHERE userName=@userName and pwd = @pwd";
        SqlParameter[] _param={new SqlParameter("@userName",userName),new SqlParameter("@pwd",pwd)};
        Object obj;
        obj= SqlParameter.ExecuteScaler(SqlHelper.sqlServierDBConnectString,CommandType.Text,sqlText,_param);
        if(obj == DBNull.Value || obj == null){
           obj = "NoThisMan";}
        return obj.To String();
    }

0 个答案:

没有答案