![]() |
#2
mpi2012-12-25 10:57
|

using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Data.SqlClient;
namespace _621007_赵武青
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "/" + "DB.mdb");
aConnection.Open();
OleDbDataAdapter myadapter = new OleDbDataAdapter("select * from jidian", aConnection);
DataSet ds = new DataSet();
myadapter.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];//将dataGridView1与ds中的内容连接起来
}
private void button2_Click(object sender, EventArgs e)
{
OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "/" + "DB.mdb");
aConnection.Open();
string strName;
strName = "insert into jidian(dianhao,X,Y,Z) values(" + textBox1.Text + ",'" + textBox2.Text + "','" + textBox3.Text + "'," + textBox4.Text + ")";
if (textBox1.Text == "" | textBox2.Text == "" | textBox3.Text == "" | textBox4.Text == "")
{
MessageBox.Show("请填写要添加的数据");
return ;
}
OleDbDataAdapter myadapter = new OleDbDataAdapter(strName, aConnection); //执行查询
DataSet ds = new DataSet(); //新建数据集
myadapter.Fill(ds);//将SQL执行结果,填入数据集ds中可自加数据,进行验证
}
private void button3_Click(object sender, EventArgs e)
{
OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "/" + "DB.mdb");
aConnection.Open();
string strName;
strName = "delete from jidian where dianhao=" + textBox1.Text;
if (textBox1.Text == "")
{
MessageBox.Show("请输入点号");
return;
}
OleDbDataAdapter myadapter = new OleDbDataAdapter(strName, aConnection);
DataSet ds = new DataSet();
myadapter.Fill(ds); ///错误是标准表达式中数据类型不匹配。
}
private void button4_Click(object sender, EventArgs e)
{
OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "/" + "DB.mdb");
aConnection.Open();
OleDbDataAdapter myadapter = new OleDbDataAdapter("select * from celiang", aConnection);
DataSet ds = new DataSet();
myadapter.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];//将dataGridView1与ds中的内容连接起来
}
private void textBox7_TextChanged(object sender, EventArgs e)
{
}
private void button5_Click(object sender, EventArgs e)
{
OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "/" + "DB.mdb");
aConnection.Open();
string strName;
strName = "insert into celiang(dianhao,测X,测Y,测Z) values(" + textBox5.Text + ",'" + textBox6.Text + "','" + textBox7.Text + "'," + textBox8.Text + ")";
if (textBox5.Text == "" | textBox6.Text == "" | textBox7.Text == "" | textBox8.Text == "")
{
MessageBox.Show("请填写要添加的数据");
return;
}
OleDbDataAdapter myadapter = new OleDbDataAdapter(strName, aConnection); //执行查询
DataSet ds = new DataSet(); //新建数据集
myadapter.Fill(ds);//将SQL执行结果,填入数据集ds中可自加数据,进行验证
}
}
}
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Data.SqlClient;
namespace _621007_赵武青
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "/" + "DB.mdb");
aConnection.Open();
OleDbDataAdapter myadapter = new OleDbDataAdapter("select * from jidian", aConnection);
DataSet ds = new DataSet();
myadapter.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];//将dataGridView1与ds中的内容连接起来
}
private void button2_Click(object sender, EventArgs e)
{
OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "/" + "DB.mdb");
aConnection.Open();
string strName;
strName = "insert into jidian(dianhao,X,Y,Z) values(" + textBox1.Text + ",'" + textBox2.Text + "','" + textBox3.Text + "'," + textBox4.Text + ")";
if (textBox1.Text == "" | textBox2.Text == "" | textBox3.Text == "" | textBox4.Text == "")
{
MessageBox.Show("请填写要添加的数据");
return ;
}
OleDbDataAdapter myadapter = new OleDbDataAdapter(strName, aConnection); //执行查询
DataSet ds = new DataSet(); //新建数据集
myadapter.Fill(ds);//将SQL执行结果,填入数据集ds中可自加数据,进行验证
}
private void button3_Click(object sender, EventArgs e)
{
OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "/" + "DB.mdb");
aConnection.Open();
string strName;
strName = "delete from jidian where dianhao=" + textBox1.Text;
if (textBox1.Text == "")
{
MessageBox.Show("请输入点号");
return;
}
OleDbDataAdapter myadapter = new OleDbDataAdapter(strName, aConnection);
DataSet ds = new DataSet();
myadapter.Fill(ds); ///错误是标准表达式中数据类型不匹配。
}
private void button4_Click(object sender, EventArgs e)
{
OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "/" + "DB.mdb");
aConnection.Open();
OleDbDataAdapter myadapter = new OleDbDataAdapter("select * from celiang", aConnection);
DataSet ds = new DataSet();
myadapter.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];//将dataGridView1与ds中的内容连接起来
}
private void textBox7_TextChanged(object sender, EventArgs e)
{
}
private void button5_Click(object sender, EventArgs e)
{
OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "/" + "DB.mdb");
aConnection.Open();
string strName;
strName = "insert into celiang(dianhao,测X,测Y,测Z) values(" + textBox5.Text + ",'" + textBox6.Text + "','" + textBox7.Text + "'," + textBox8.Text + ")";
if (textBox5.Text == "" | textBox6.Text == "" | textBox7.Text == "" | textBox8.Text == "")
{
MessageBox.Show("请填写要添加的数据");
return;
}
OleDbDataAdapter myadapter = new OleDbDataAdapter(strName, aConnection); //执行查询
DataSet ds = new DataSet(); //新建数据集
myadapter.Fill(ds);//将SQL执行结果,填入数据集ds中可自加数据,进行验证
}
}
}