错误是标准表达式中数据类型不匹配。
程序代码:
错误出现在最下面一行。其他的度可以执行!求高手指点,期末作业!原因也写出来了! 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); ///错误是标准表达式中数据类型不匹配。