InStr(string1,string2)中怎样总是说string2的字符数太多啊,应该怎样解决啊

解决方案 »

  1.   

    InStr方法是什么?贴完整的代码看一下。还有string2也看一下
      

  2.   

    string str="tanlin"; 
    string strUpdate = "update FileTable set cFilePath=Left(cFilePath,InStr(cFilePath,'"+str+"')) where cFilePath like '文件管理\\tanlin%'";
       DataOperate.ExecuteNonQuery(strUpdate);
      

  3.   

    start 
    可选项。数值表达式,用于设置每次搜索的开始位置。如果省略,将从第一个字符的位置开始搜索。如果 start 包含 Null,则会出现错误。如果已指定 compare,则必须要有 start 参数。 
    string1 
    必选项。接受搜索的字符串表达式。 
    string2 
    必选项。要搜索的字符串表达式。 
    compare 
    可选项。指示在计算子字符串时使用的比较类型的数值。有关数值,请参阅“设置”部分。如果省略,将执行二进制比较。 
    设置第二个串不应长过第一个串...
      

  4.   

    InStr()有这么个方法? 自己写的啊
      

  5.   

    string strUpdate = "update FileTable set cFilePath=Left(cFilePath,InStr(cFilePath,'"+str+"')) where len(cFilePath)>=len('" + str + "')  cFilePath like '文件管理\\tanlin%'"; 好些年不针对access写sql了
      

  6.   

    也不对啊,它报错了,说InStr(cFilePath,'"+str+"')中str的字符太多啊
      

  7.   

    string strUpdate = "update FileTable set cFilePath=Left(cFilePath,InStr(cFilePath,'"+str+"')) where len(cFilePath)>=len('" + str + "') and cFilePath like '文件管理\\tanlin%'";刚才本身写得就有错
      

  8.   

    我写对了,它也报错啊!就是说InStr(cFilePath,'"+str+"')中str的字符太多啊
      

  9.   

    具体报错信息呢??是sql执行错,还是语句错?
      

  10.   

    sql执行没错,语句也没错。都没报错,就是没改,我执行string strUpdate = "update FileTable set cFilePath=Left(cFilePath,5) where cFilePath like '文件管理\\tanlin%'"; 能改
    我快速监视了一下InStr(cFilePath,'"+str+"')的值,说是字符文本中的字符太多
      

  11.   

    ......那你在问什么??...这个是字符串赋值,我还以为是instr出错了...
      

  12.   

    这个是InStr(cFilePath,'"+str+"')错了,说是字符文本中的字符太多 不知道应该怎样改啊
      

  13.   

    那你可以对比一下,是不是你放入到string2中的字符中有什么特别的地方,还有你可以有可能打开InStr中看看方法的源程序。