数据库为Access
有表A
表中有字段:B,C现在窗口中有textbox1,textbox,boutton1按下boutton1如何判断textbox1,textbox与字段B,C相等的时候往下执行?

解决方案 »

  1.   

    textbox1,textbox2要同时与B,C相等的时候,才往下执行,
    求代码,急,高手帮帮忙,在线给分
      

  2.   

    不理解
    textbox1=textbox2?
    或者
    textbox1=b?&& textbox2=c?
    还是全部相等?
    ps:俺不是高手……
      

  3.   


    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Data.OleDb;
    namespace WindowsApplication1
    {
        public partial class Form1 : Form
        {        public Form1()
            {
                InitializeComponent();        }        private void button1_Click(object sender, EventArgs e)
            {
                OleDbConnection conn = new OleDbConnection(@"链接字符串");
                string cmd = @"select * from A where B=@B and C=@C";
                OleDbCommand comm = new OleDbCommand(cmd, conn);
                comm.Parameters.AddWithValue("@B", textBox1.Text);
                comm.Parameters.AddWithValue("@C", textBox2.Text);
                conn.Open();
                OleDbDataReader rd = comm.ExecuteReader();
                if (rd.Read()){
                    //找到相同的
                }
                else {
                    //没有找到
                }            //或者
                //int n = comm.ExecuteNonQuery();
                //if (n > 0){
                //    //找到相同的
                //}
                //else
                //{
                //    //没有找到
                //}            conn.Close();
            }
        }
    }
      

  4.   

    if(textbox1.text != b.value || textbox2.text != c.value)
    {
     return;
    }