-3

我在调试程序时出错,说无法将“System.Data.DataSet”类型的对象转换为 MyDatabase.DataSet 类型

我需要做什么来修复它

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;
        }

    }
4

1 回答 1

0

我认为问题出在这一行:

o_Find = (DataSet)oUsers.FindData(strUser,strPass);

您似乎在代码中的某处覆盖了 DataSet 的含义。(例如什么是 type MyDatabase.DataSet?)

这应该可以解决问题:

o_Find = (System.Data.DataSet)oUsers.FindData(strUser,strPass);
于 2013-03-05T03:43:32.680 回答