本文介绍了解析查询时出错。 [令牌行号= 1,令牌行偏移= 27,令牌错误=用户]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlServerCe;
namespace khtwa
{
    public partial class Form1 : Form
    {


        public Form1()
        {
            InitializeComponent();
        }
        string msg;



        SqlCeCommand cmd;
        DataSet ds = new DataSet();
        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            textBox1.Text = "";
                textBox2.Text="";

                this.Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            string y = (Application.StartupPath + "\\font.sdf");
             SqlCeConnection con = new SqlCeConnection(@"Data Source=" + y);
             con.Open();
                if (textBox1.Text == "" || textBox2.Text == "")
                {
                    MessageBox.Show(" Enter UserName and Password .");
                    return;
                }

                cmd = new SqlCeCommand("SELECT * FROM login where user='" + textBox1.Text + "' and password='" + textBox2.Text + "'", con);
                SqlCeDataAdapter da = new SqlCeDataAdapter(cmd);

                da.Fill(ds);
                int i = ds.Tables[0].Rows.Count;
                if (i == 1)
                {
                    msg = "Welcome " + textBox1.Text;
                    this.Hide();
                    Form2 f2 = new Form2();
                    f2.Show();
                    ds.Clear();

                }
                else
                {
                    MessageBox.Show("Not Registered User or Invalid Name/Password");
                    textBox2.Text = "";
                }
            }



        }
    }

推荐答案


这篇关于解析查询时出错。 [令牌行号= 1,令牌行偏移= 27,令牌错误=用户]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 21:01