110,539
社区成员
发帖
与我相关
我的任务
分享
[csharp] view plaincopyprint?
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.SqlClient;
namespace My_SQL
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this.BindingContext[this.dataSet31, "Class1"].Position--;
}
private void button2_Click(object sender, EventArgs e)
{
this.BindingContext[this.dataSet31, "Class1"].Position++;
}
private void Form3_Load(object sender, EventArgs e)
{
comboBox1.Items.Clear();
comboBox1.DataSource = dataSet31.Tables["Class1"];
comboBox1.DisplayMember = "Naem";
this.sqlDataAdapter1.Fill(this.dataSet31, 0, 0, "Class1");
}
private void button3_Click(object sender, EventArgs e)
{
int dds = comboBox1.SelectedIndex;
string ds = comboBox1.Text;
SqlConnection con1 = new SqlConnection("Data Source=(local);database=msdb;Integrated Security=SSPI");
SqlCommand cmd = new SqlCommand("select Age,sex,address from Class1 where naem='"+ds+"'", con1);
con1.Open();
SqlDataReader dr=cmd.ExecuteReader();
if (dr.Read())
{
this.textBox7.Text = dr[1].ToString();
this.textBox8.Text = dr[2].ToString();
this.textBox6.Text = dr[0].ToString();
this.BindingContext[this.dataSet31, "Class1"].Position = dds;
}
dr.Close();
con1.Close();
}
}
}
if (!(comboBox3.DisplayMember == "Naem"))
结贴给分!![/quote]
呃!应该是 if (!(comboBox1.DisplayMember == "Naem"))
-_-!!!
if (!(comboBox3.DisplayMember == "Naem"))
结贴给分!!