我用的是C#不过我可以告诉你大概的思路吧。点击list1在属性里找到(bindingsource)把加好点开有个text属性把他绑定到diaodu的车辆编号
list2类似,在这个之前你要先添加数据源。
下面是C#的语句:
public partial class Form3 : Form
{
System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter();
System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection();
System.Data.DataSet ds = new DataSet();
System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand();
System.Windows.Forms.BindingSource bs1 = new BindingSource();
public Form3()
{
InitializeComponent();
conn.ConnectionString = "Data Source=BAOBAO\\SQLEXPRESS;Initial Catalog=sim;Integrated Security=True";
cmd.CommandText = "select * from s_infor";
cmd.Connection = conn;
da.SelectCommand = cmd;
}
private void Form3_Load(object sender, EventArgs e)
{
// TODO: 这行代码将数据加载到表“simDataSet.s_infor”中。您可以根据需要移动或移除它。
this.s_inforTableAdapter.Fill(this.simDataSet.s_infor);
}
private void tabPage1_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
string zhuanye = this.textBox1.Text;
string sushe = this.textBox2.Text;
string age = this.textBox3.Text;
string sex = this.textBox4.Text;
string num = this.textBox5.Text;
string name = this.textBox6.Text;
string xibie = this.textBox7.Text;
string birthday = this.maskedTextBox1.Text;
cmd.CommandText = "insert into s_infor values ('" + zhuanye + "','" + sushe + "','" + age + "','" + sex + "','" + num + "','" + name + "','" + xibie + "','" + birthday + "')";
cmd.Connection = conn;
try
{
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
this.label25.Text = "操作成功!";
}
catch
{
this.label25.Text = "操作失败!";
}
}
private void button13_Click(object sender, EventArgs e)
{
this.sinforBindingSource7.MoveFirst();
}
private void button14_Click(object sender, EventArgs e)
{
this.sinforBindingSource7.MovePrevious();
}
private void button15_Click(object sender, EventArgs e)
{
this.sinforBindingSource7.MoveNext();
}
private void button16_Click(object sender, EventArgs e)
{
this.sinforBindingSource7.MoveLast();
}
private void button17_Click(object sender, EventArgs e)
{
this.s_inforTableAdapter.Fill(this.simDataSet.s_infor);
}
private void button18_Click(object sender, EventArgs e)
{
this.textBox1.Text = "";
this.textBox2.Text = "";
this.textBox3.Text = "";
this.textBox4.Text = "";
this.textBox5.Text = "";
this.textBox6.Text = "";
this.textBox7.Text = "";
this.maskedTextBox1.Text = "";
this.label25.Text= "";
}
private void button3_Click(object sender, EventArgs e)
{
string s_num = this.textBox5.Text;
cmd.CommandText = "delete s_infor where s_num='" + s_num + "'";
cmd.Connection = conn;
try
{
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
this.label25.Text = "操作成功!";
}
catch
{
this.label25.Text = "操作失败!";
}
}
private void button2_Click(object sender, EventArgs e)
{
string zhuanye = this.textBox1.Text;
string sushe = this.textBox2.Text;
string age = this.textBox3.Text;
string sex = this.textBox4.Text;
string num = this.textBox5.Text;
string name = this.textBox6.Text;
string xibie = this.textBox7.Text;
string birthday = this.maskedTextBox1.Text;
cmd.CommandText="update s_infor set s_name='"+ name + "',s_zhuanye='"+ zhuanye + "',s_sushe='"+ sushe + "',s_age='"+ age + "',s_sex='"+ sex + "',s_num='"+ num + "',s_xibie'"+ xibie + "',s_birthday='"+ birthday + "'";
cmd.Connection = conn;
try
{
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
this.label25.Text = "操作成功!";
}
catch
{
this.label25.Text = "操作失败!";
}
}
private void button4_Click(object sender, EventArgs e)
{
string num = this.textBox5.Text;
cmd.CommandText = "Select '" + num + "' from s_infor";
cmd.Connection = conn;
try
{
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
this.label25.Text = "操作成功!";
}
catch
{
this.label25.Text = "操作失败!";
}
}
}
}
等我装个VB,帮你做做看。
我倒是想做 不过公司没装VB 等到家再说吧。。。