无法绑定多部件标识符textBox1.Text。无法绑定多部件标识符textBox2.Text。 [英] Multi part identifier textBox1.Text could not be bound. Multi part identifier textBox2.Text could not be bound.

查看:114
本文介绍了无法绑定多部件标识符textBox1.Text。无法绑定多部件标识符textBox2.Text。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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 WindowsFormsApplication3
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection
                            (@"Data Source=LEAPTHOUGHT\SQLEXPRESS;Initial Catalog=master;Integrated Security=True");
            SqlDataAdapter sda = new SqlDataAdapter("Select Count(*) from Login where UserName = ''+textBox1.Text + '' and Password= ''+ textBox2.Text +'' ",conn);

            DataTable dt = new DataTable();
            sda.Fill(dt);
            if (dt.Rows[0][0].ToString() == "1")
            {
                this.Hide();
                Form2 form2 = new Form2();
                form2.ShowDialog();
            }
            else
            {
                MessageBox.Show("Please check your login credentials");
            }


        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

    }
}

推荐答案

将代码更改为



Change code to

SqlDataAdapter sda = new SqlDataAdapter("Select Count(*) from Login where UserName = '"+textBox1.Text + "' and Password= '"+ textBox2.Text +"' ",conn);


这篇关于无法绑定多部件标识符textBox1.Text。无法绑定多部件标识符textBox2.Text。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆