make sure you can read first:OleDbConnection oConn = new OleDbConnection(sConn);
OleDbCommand oCmd = new OleDbCommand( sSQL, oConn );
oConn.Open();
oCmd.CommandText = "Select count(*) as Count from owner.TABLE";
int n = (int)oCmd.ExecuteScalar();
oConn.Close();
oConn.Dispose();

解决方案 »

  1.   

    我在SQL Plus中执行Update都是行了.
    并且按照你的刚才写的那代码,曾经执行过 SELECT * FROM 的子句,是没有问题的,能返回 DataTable来。
    只要做更新操作就出问题了。在SQL Plus中做更新没有问题。
      

  2.   

    思归,楼主,我也遇到类似问题,我是在自己机器上好好的程序,放到另一台机器上,access数据库就只能执行读操作,不能执行写操作了,提示出错“操作没有可更新的查询”
      

  3.   

    cyndi(下雨) , that is different, you probably forgot to give ASPNET account read/write permissions on the database file and the folder it is in
      

  4.   

    the program hung and you didn't get errors? can you just tryUPDATE YourTABLEName SET FIELD1 = 'C' WHERE FIELD2 = '7C'
      

  5.   

    Provider="OraOLEDB.Oracle.1";User ID=escmuser;Data Source=escm;Extended Properties=;Persist Security Info=True;Password=escmuser
    连接串没问题吧?试试
    Provider=MSDAORA.1;Password=escmuser;User ID=escmuser;Data Source=escm
      

  6.   

    链接字符串我是用的ODBC链接的。我在测试读数据时是没有问题的。
    是不是在链接字符串中还要设置其它什么东东?比如:Extended Propertores=???
      

  7.   

    if you can do "SELECT", then it means your connection string is ok, you can remove 
    "Extended Properties=;Persist Security Info=True;"it is weird that your program hung instead of giving your errors, sounds like a lock problem, but that will give you an eventual error
      

  8.   

    换过好多链接字符串都不行.程序就是没有反应.也不提示任何错误.然后整个窗品就死掉了.一、Provider=MSDAORA.1;Password=escmuser;User ID=escmuser;Data Source=escm
    二、Provider="OraOLEDB.Oracle";User ID=escmuser;Data Source=escm;Extended Properties=;Persist Security Info=True;Password=escmuser
    三、Provider="OraOLEDB.Oracle";User ID=escmuser;Data Source=escm;Password=escmuser
    三、Provider="OraOLEDB.Oracle.1";User ID=escmuser;Data Source=escm;Extended Properties=;Persist Security Info=True;Password=escmuser
    四、Provider="OraOLEDB.Oracle.1";User ID=escmuser;Data Source=escm;Password=escmuser
      

  9.   

    string StrSbbh = txtsbbh.Text.Trim();
    OleDbConnection Conxxwgl = new OleDbConnection(ConfigurationSettings.AppSettings["ConnXxwgl"]);
    string Str1 = "select count(*) from xxwt_sb_jbxx where sbbh = '" + StrSbbh +"'";

    OleDbCommand OleCmdMsg = new OleDbCommand(Str1,Conxxwgl);
    Conxxwgl.Open();
                int intCount = int.Parse(OleCmdMsg.ExecuteScalar().ToString());
                 Conxxwgl.Close();
    if (intCount>0)
    {
    string StrJsjm = "select jsjm from xxwt_sb_jbxx where sbbh = '" + StrSbbh +"'";
    OleDbCommand OleCmdMsg1 = new OleDbCommand(StrJsjm,Conxxwgl);
    Conxxwgl.Open();
    txtjsjm.Text  =  OleCmdMsg1.ExecuteScalar().ToString();
    Conxxwgl.Close();

    }
    else
    {
    Response.Write("<script language='javascript'>alert('没有对应的计算机名称!')</script>"); }
      

  10.   

    大哥:我的问题是在用UPDATE时出错.整个窗口的进程就死掉了.
    你把你的那段ConfigurationSettings.AppSettings["ConnXxwgl"]的值告诉我???
      

  11.   

    加上错误提示看看会显示什么错误:
    try
    {
      //你的可执行代码;
    }
    catch(Exception err)
    {
      Debug.Fial(err.Message);//记得添加引用using System.Diagnostics;
    }