向ACCESS库中保存html的时候如果有'号就会出现以下错误:语法错误 (操作符丢失) 在查询表达式 ''<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>一起去看书_177ks_书籍列表页</title> <title>一起去看书____</title> <met' 中。
解决方案 »
- 如何检查出本机是否安装dotnet framework v4.0,如果没有则直接打开下载链接?
- winform 实现打开ie实现登陆 求助
- 求List排序)(全部家当奉上)
- 怎么打印图片呢?
- 一个简单的XML转换问题
- 如何在已经打开的数据源在筛选数据?
- 如何从框架页跳出,重新按非框架的模式打开本页?
- 初学者提问:c#中如何读出Excle中的数据
- 在C#中使用DataGridView 控件 完成网页上的增加 删除 查询 功能 怎么实现啊 ?哪位高手能写个代码给我,我是菜鸟~ 我在线等
- 我是个新手想学习C#
- 如何添加System.Drawing.Point类型的资源?
- 那个大侠能提供一些搜索引擎这方面的代码一起来讨论指点~!谢谢~
比如 ADODB.RECORDSET.OPEN 以后再UPDATE你必定要用 SQL 来保存的话请格式化字串,比如update table set fieldname =' ''<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> '看见第一个单引号了么?要重复两遍,按你编写代码的环境不同,可能其中的双引号也全部要重复两遍 ,第一个引号是作为转义字符用的
/// <summary>
/// 转换非法字符
/// </summary>
/// <param name="str"></param>
/// <returns></returns> public static string strEncode(string str)
{
if(str!=null)
{
System.Text.StringBuilder newstr=new System.Text.StringBuilder();
string xChar="";
int l=str.Length;
for(int i=0;i<l;i++)
{
xChar=str.Substring(i,1);
switch(xChar)
{
case("\'"):
newstr.Append("‘");
break;
case("\""):
newstr.Append("“");
break;
case("("):
newstr.Append("(");
break;
case(")"):
newstr.Append(")");
break;
case(":"):
newstr.Append(":");
break;
case("<"):
newstr.Append("<");
break;
case(">"):
newstr.Append(">");
break;
default:
newstr.Append(xChar);
break;
}
}
return newstr.ToString();
}
else
return null;
} #endregion
#region 转换非法字符(文本框格式内容转换)
/// <summary>
/// 转换非法字符
/// </summary>
/// <param name="str"></param>
/// <param name="style">Text</param>
/// <returns></returns> public static string strEncode(string str,string style)
{
if(str!=null)
{ System.Text.StringBuilder newstr=new System.Text.StringBuilder();
string xChar="";
int l=str.Length;
if(style=="xml")
{
for(int i=0;i<l;i++)
{
xChar=str.Substring(i,1);
switch(xChar)
{
case("\'"):
newstr.Append("‘");
break;
case("\""):
newstr.Append("“");
break;
case("("):
newstr.Append("(");
break;
case(")"):
newstr.Append(")");
break;
// case(":"):
// newstr.Append(":");
// break;
case("<"):
newstr.Append("<");
break;
case(">"):
newstr.Append(">");
break;
/* case(" "):
newstr.Append(" ");
break;
case("\n"):
* newstr.Append("<br>");
break;
case("\r"):
newstr.Append("<br>");
break; */ default:
newstr.Append(xChar);
break;
}
}
}
else
{
for(int i=0;i<l;i++)
{
xChar=str.Substring(i,1);
switch(xChar)
{
case("\'"):
newstr.Append("‘");
break;
case("\""):
newstr.Append("“");
break;
case("("):
newstr.Append("(");
break;
case(")"):
newstr.Append(")");
break;
case(":"):
newstr.Append(":");
break;
case(" "):
newstr.Append(" ");
break;
case("<"):
newstr.Append("<");
break;
case(">"):
newstr.Append(">");
break;
case("\n"):
newstr.Append("<br>");
break;
case("\r"):
newstr.Append("<br>");
break; default:
newstr.Append(xChar);
break;
}
}
}
return newstr.ToString();
}
else
return null;
} #endregion #region 反向转换非法字符
/// <summary>
/// 反向转换非法字符
/// </summary>
/// <param name="str"></param>
/// <returns></returns> public static string strUNEncode(string str)
{
str=str.Replace("“","\"");
str=str.Replace("‘","\'");
str=str.Replace(")",")");
str=str.Replace("(","(");
return str;
} #endregion
#region 反向转换非法字符(文本框内容转换)
/// <summary>
/// 反向转换非法字符
/// </summary>
/// <param name="str"></param>
/// <param name="style">text为文本框格式的</param>
/// <returns></returns> public static string strUNEncode(string str,string style)
{
str=str.Replace("“","\"");
str=str.Replace("‘","\'");
str=str.Replace(")",")");
str=str.Replace("(","(");
str=str.Replace(">",">");
str=str.Replace("<","<");
str=str.Replace(" "," ");
str=str.Replace("<br>","\n"); return str;
}
}
}