简体   繁体   English

System.Data.dll 430中发生类型为'System.InvalidOperationException'的未处理异常

[英]An unhandled exception of type 'System.InvalidOperationException' occurred in System.Data.dll 430

the da.fill(ds) is giving me an An unhandled exception of type 'System.InvalidOperationException' occurred in System.Data.dll da.fill(ds)给我一个System.Data.dll中发生的'System.InvalidOperationException'类型的未处理异常

I'm not 100% sure why this error is here but I know it appeared after I attempted this login code. 我不确定100%为何会出现此错误,但我知道在尝试登录代码后会出现此错误。

 using (SqlConnection con = new SqlConnection("Data Source=c:\\RegistrationMDB.accdb"))
            {
                SqlDataAdapter da = new SqlDataAdapter();
                DataSet ds = new DataSet();
                SqlCommand cmd = new SqlCommand("SELECT ID, PASSWORD FROM Students WHERE ID = @ID OR PASSWORD = @PASSWORD", con);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add("@ID", SqlDbType.VarChar).Value = id;
                cmd.Parameters.Add("@PASSWORD", SqlDbType.VarChar).Value = pw;


                da.Fill(ds);
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    iD = (dr["@ID"].ToString());
                    password = dr["@PASSWORD"].ToString();
                }

                if (iD == id && password == pw)
                {
                    return true;
                }
                else
                {
                    LogNotification = "ID/Password is incorrect";
                    return false;
                }
            }
        }
da.SelectCommand = cmd;

da.Fill(ds);之前da.Fill(ds);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 发生未处理的异常C#的system.data.dll中发生了类型'system.invalidoperationexception'的未处理异常 - An unhandled exception occured an unhandled exception of type 'system.invalidoperationexception' occurred in system.data.dll in c# System.Data.dll中发生类型为'System.InvalidOperationException'的未处理异常-C#Visual Studio - An unhandled exception of type 'System.InvalidOperationException' occurred in System.Data.dll - C# visual studio System.Data.dll 中发生类型为“System.InvalidOperationException”的未处理异常? - An unhandled exception of type 'System.InvalidOperationException' occurred in System.Data.dll? C# 中的 System.Data.dll 中发生了“System.InvalidOperationException”类型的未处理异常 - An unhandled exception of type 'System.InvalidOperationException' occurred in System.Data.dll in C# System.Data.dll (SqlTransaction) 中出现“System.InvalidOperationException”类型的未处理异常 - An unhandled exception of type 'System.InvalidOperationException' occurred in System.Data.dll (SqlTransaction) 当我尝试将数据插入文本框时,System.Data.dll中发生了类型为'System.InvalidOperationException'的未处理异常 - An unhandled exception of type 'System.InvalidOperationException' occurred in System.Data.dll when I tried to insert data into textbox 从文本框写入sql server 2012时,System.Data.dll中发生类型为'System.InvalidOperationException'的未处理异常 - An unhandled exception of type 'System.InvalidOperationException' occurred in System.Data.dll While writing from textbox to sql server 2012 将数据插入Gridview的System.Data.dll中发生类型为'System.InvalidOperationException'的异常 - An exception of type 'System.InvalidOperationException' occurred in System.Data.dll that inserting data into Gridview System.Data.dll 中发生类型为“System.InvalidOperationException”的第一次机会异常 - A first chance exception of type 'System.InvalidOperationException' occurred in System.Data.dll ExecuteReader- System.Data.dll中发生类型为“System.InvalidOperationException”的异常,但未在用户代码中处理 - ExecuteReader- An exception of type 'System.InvalidOperationException' occurred in System.Data.dll but was not handled in user code
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM