"select * from table1 where id=xid"
改为:
select * from table1 where id="+xid.ToString(),

解决方案 »

  1.   

    "select * from table1 where id=xid"
    这样写相当于你的id=xid
    而不是xid所代表的值
    改称
    "select * from table1 where id=" + xid
    就好
      

  2.   

    select * from table1 where id="+xid.ToString(),
      

  3.   

    老大,你的xid不是变量么,怎么能与前面的SQL语句写到一起呢
    你可以把这行
    OleDbDataAdapter mc=new OleDbDataAdapter("select * from table1 where id=xid",myOleDbConnection);
    改成这样试试:
    string SQL_Text;
    SQL_Text = "select * from table1 where id="xid;
    OleDbDataAdapter mc=new OleDbDataAdapter(SQL_Text,myOleDbConnection);
      

  4.   

    上面错了一句,不好意思,呵呵
    string SQL_Text;
    SQL_Text = "select * from table1 where id="+xid;
    OleDbDataAdapter mc=new OleDbDataAdapter(SQL_Text,myOleDbConnection);
      

  5.   

    OleDbDataAdapter mc=new OleDbDataAdapter("select * from table1 where id='"+xid+"'",myOleDbConnection);
      

  6.   

    根据你的int xid=int.Parse(id)语句判断你要查询的数据库中的id字段类型为int型
    所以使用:
    OleDbDataAdapter mc=new OleDbDataAdapter("select * from table1 where id="+xid,myOleDbConnection);你试试看行不行?对于清明兄的代码有一点疑义就是你的写法对于id类型为char、varchar等字符类型是有效的,但这里的id应该是int型吧?
    如果说的不准确,请原谅~