运行调试器查看错误后出现此错误:
“无法将‘System.Data.DataSet’类型的对象转换为‘NLHosp.DataSet’类型”
“NLHosp”是我的数据库的名称。
这是代码:
private void btnLogin_Click(object sender, System.EventArgs e)
{
string strUser;
string strPass;
string sMsg = "";
strUser = txtUserID.Text ;
strPass = txtPassword.Text ;
DataSet o_Find = new DataSet ();
Users oUsers = new Users();
try
{
o_Find = (DataSet)oUsers.FindData(strUser,strPass);
sMsg = "Welcome " + o_Find.Tables ["Login"].Rows[0]["UserName"].ToString ();
switch (strUser)
{
case "Admissions":
frmAdmissions admitForm = new frmAdmissions ();
admitForm.Visible = true;
admitForm.Activate();
break;
case "Admin":
case "Nurse":
case "Doctor":
frmMenu menuForm = new frmMenu ();
menuForm.oCurrent.UserName = strUser;
menuForm.Visible = true;
menuForm.Activate();
menuForm.SelectUser();
break;
}
}