nan... 2021-11-21 23:08 采纳率: 58.3%
浏览 68
已结题

为什么她说我的“Login”未能找到类型或命名空间(是否缺少using指令或程序集引用这是什么原因?)我应该怎么改啊

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace qizhongtu
{
public partial class MainFrm : Form
{
private bool isLogined = false;
private Login orm;

    public object Login { get; private set; }

    public MainFrm()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {

    }

    private void btnYes_Click(object sender, EventArgs e)
    {
        string userName = txtName.Text;

        string password = txtPwd.Text;

        string connString = @"Data Source=.\ sqlexpress; Initial Catalog=qizhongtu;Integrated Security=true";

        SqlConnection conn = new SqlConnection(connString);

        string sql = String.Format("select count (*) from [User] where UserName = ' (0)' and password = ' (1)'", userName, password);

        try
        {
            conn.Open();

            SqlCommand comm = new SqlCommand(sql, conn);

            //创建Command对象

            int n = (int)comm.ExecuteScalar();

            //执行查询语句,返回匹配的行数

            if (n == 1)
            {

                this.DialogResult = DialogResult.OK;
                this.Tag = true;//登录成功并记录
            }

            else
            {
                MessageBox.Show("您输人的用户名或密码错误!请重试", "登录失败", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                this.Tag = false; // 登录失败并记录
            }
        }

        catch (Exception ex)
        {

            MessageBox.Show(ex.Message, "操作数据库出错!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            this.Tag = false;
        }

        finally

        {
       
  • 写回答

1条回答 默认 最新

  • zxpei 2021-11-22 13:16
    关注

    object Login 中object表示的是类型层次的根,Login只是一个object类型的对象。
    所以你应该在你现在这个类的外面定义一个Login类。
    public class Login
    {
    }

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 12月22日
  • 已采纳回答 12月14日
  • 创建了问题 11月21日

悬赏问题

  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 Macbookpro 连接热点正常上网,连接不了Wi-Fi。
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程
  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)