yjf4819 2015-01-06 11:13 采纳率: 0%
浏览 2399

C# ACCeSS Update 标准表达式中数据类型不匹配?

用C#写的程序, 目的是处理表格 Access, 想把表格中的某行删除! 然后在用Update,方法,总是报错!代码如下:
//删除空行,删除
private void button2_Click(object sender, EventArgs e)
{
//根据Excel的行逐一对上面构造的DataTable的列进行赋值
int i = 0;
// int temp=0;
int coun = this.dataGridView.RowCount;

 //  20150105  ,打开数据库
       string filepath = AppDomain.CurrentDomain.BaseDirectory + "Database1.mdb";
       string dbfile = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+filepath ;         
       OleDbConnection oleDbConn = new OleDbConnection();
       oleDbConn.ConnectionString = @dbfile;
       oleDbConn.Open();    

 //建立adapter
       OleDbDataAdapter myadapter = null;
       string strdata = "select  * from   excelData";
       myadapter = new OleDbDataAdapter(strdata, oleDbConn);
       OleDbCommandBuilder mybuilder = new OleDbCommandBuilder(myadapter); // 20150105 不加报错  

       DataSet ds = null;
       ds = new DataSet();

       myadapter.Fill(ds, "table1");    // table1 就是新建的表格名字
       //根据DataGridView的列构造一个新的DataTable
    //   DataTable dtone = new DataTable();
       DataTable  dtone = ds.Tables["table1"];
       this.dataGridView.DataSource  = dtone;

       DataColumn[] myPrimaryKey = new DataColumn[1];
       myPrimaryKey[0] = dtone.Columns["ID"];
       dtone.PrimaryKey = myPrimaryKey;

       DataRow myRemoveRow = dtone.Rows.Find("20"); //步骤3

       myRemoveRow.Delete();![![图片说明](https://img-ask.csdn.net/upload/201501/06/1420542791_901431.jpg)图片说明](https://img-ask.csdn.net/upload/201501/06/1420542779_623497.jpg)
  • 写回答

3条回答

报告相同问题?

悬赏问题

  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题