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(); } } }
求代码,急,高手帮帮忙,在线给分
textbox1=textbox2?
或者
textbox1=b?&& textbox2=c?
还是全部相等?
ps:俺不是高手……
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();
}
}
}
{
return;
}