轉換成ASCII碼﹐顯示時再轉回去﹗

解决方案 »

  1.   

    用下面的方法转换:
    传入要转换的字符串;
    private string replacetext(string text)
    {
        return text.Replace("'","''");
    }
      

  2.   

    TO covis(covis):既然C#字符串有了内嵌的函数,为什么还要我自定义一个函数呢?
      

  3.   

    用传参数的方式,就不存在这种问题了
    public DataSet GetOwnStorage()
    {
    DataSet dataSet= new DataSet() ;
    firstCommand = new OleDbCommand(@"Select * from Maa where Storageid = ?)",new OleDbConnection(ClsDbConnect.ConnectionString ));
    OleDbParameter param = new OleDbParameter("@UID", OleDbType.VarChar);
    param.Value = "2342'134'";
    firstCommand.Parameters.Add(param) ;
    dsCommand.SelectCommand = firstCommand;
    dsCommand.Fill(dataSet) ;
    return dataSet; }
      

  4.   

    同意 Lovest(大法师),最稳妥的方式是传参数。
      

  5.   

    如果是这样的呢?WHERE MusicName LIKE '%Let's go!%'这个SQL查询语句里面要查询的字符含有 ' 这个字符造成SQL语句执行错误 怎么解决?