asp常用的正则表达式实现字符串的替换,主要包括去除html标签,去除class标签和去除script标签等
去除html标签正则<\/*[^<>]*>
Function LoseHtml(ContentStr)
Dim ClsTempLoseStr,RegEx
ClsTempLoseStr = Cstr(ContentStr)
Set RegEx = New RegExp
RegEx.Pattern = "<\/*[^<>]*>"
RegEx.IgnoreCase = True
RegEx.Global = True
ClsTempLoseStr = RegEx.Replace(ClsTempLoseStr,"")
Set RegEx = Nothing
LoseHtml = ClsTempLoseStr
End function
去除网页中的class
Function LoseClassTag(ContentStr)
Dim ClsTempLoseStr,RegEx
ClsTempLoseStr = Cstr(ContentStr)
Set RegEx = New RegExp
RegEx.Pattern = "(class=){1,}(""|\'){0,1}\S+(""|\'|>|\s){0,1}"
RegEx.IgnoreCase = True
RegEx.Global = True
ClsTempLoseStr = RegEx.Replace(ClsTempLoseStr,"")
LoseClassTag = ClsTempLoseStr
Set RegEx = Nothing
End Function
Function LoseScriptTag(ContentStr)
Dim ClsTempLoseStr,RegEx
ClsTempLoseStr = Cstr(ContentStr)
Set RegEx = New RegExp
RegEx.Pattern = "(<script) ......
<%
SQL1 = "update table1 set a=b where id=1"
Conn.ExeCute SQL1
SQL2 = "update table2 set a=b where id=2"
Conn.ExeCute SQL2
SQL3 = "update table3 set a=b where id=3"
Conn.ExeCute SQL3
%>
事实上,这是一种效率很低下的写法,为了提高SQL的执行效率,我们可以把多个SQL语句用分号拼接在一起,然后一次性交给Conn来执行。如下:
<%
SQL1 = "update table1 set a=b where id=1"
SQL2 = "update table2 set a=b where id=2"
SQL3 = "update table3 set a=b where id=3"
SQL = SQL1 & ";" & SQL2 & ";" & SQL3
Conn.ExeCute SQL
%>
但是,以上2种写法都会面临一个问题,就是当我们需要保证3条SQL语句都必须完整执行,当某一条执行错误时,其他2条也跟着回滚时,我们就需要用到SQLServer的事务控制了,不少的文章建议使用以下方法:
<%
dim Conn=Server.CreateObj ......
<%
SQL1 = "update table1 set a=b where id=1"
Conn.ExeCute SQL1
SQL2 = "update table2 set a=b where id=2"
Conn.ExeCute SQL2
SQL3 = "update table3 set a=b where id=3"
Conn.ExeCute SQL3
%>
事实上,这是一种效率很低下的写法,为了提高SQL的执行效率,我们可以把多个SQL语句用分号拼接在一起,然后一次性交给Conn来执行。如下:
<%
SQL1 = "update table1 set a=b where id=1"
SQL2 = "update table2 set a=b where id=2"
SQL3 = "update table3 set a=b where id=3"
SQL = SQL1 & ";" & SQL2 & ";" & SQL3
Conn.ExeCute SQL
%>
但是,以上2种写法都会面临一个问题,就是当我们需要保证3条SQL语句都必须完整执行,当某一条执行错误时,其他2条也跟着回滚时,我们就需要用到SQLServer的事务控制了,不少的文章建议使用以下方法:
<%
dim Conn=Server.CreateObj ......
<%
SQL1 = "update table1 set a=b where id=1"
Conn.ExeCute SQL1
SQL2 = "update table2 set a=b where id=2"
Conn.ExeCute SQL2
SQL3 = "update table3 set a=b where id=3"
Conn.ExeCute SQL3
%>
事实上,这是一种效率很低下的写法,为了提高SQL的执行效率,我们可以把多个SQL语句用分号拼接在一起,然后一次性交给Conn来执行。如下:
<%
SQL1 = "update table1 set a=b where id=1"
SQL2 = "update table2 set a=b where id=2"
SQL3 = "update table3 set a=b where id=3"
SQL = SQL1 & ";" & SQL2 & ";" & SQL3
Conn.ExeCute SQL
%>
但是,以上2种写法都会面临一个问题,就是当我们需要保证3条SQL语句都必须完整执行,当某一条执行错误时,其他2条也跟着回滚时,我们就需要用到SQLServer的事务控制了,不少的文章建议使用以下方法:
<%
dim Conn=Server.CreateObj ......
我想用C#实现象ASP中的
rs.addnew
rs( "a ") = "aaa "
rs( "b ") = 123
rs.update
这样方法添加数据,问一下,要怎么做啊?
具体方法如下
string dbPath = "../App_data/WebSeven.mdb ";
string db = Server.MapPath(dbPath);
string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " + db;
string strSQL = "SELECT [Svn_title],Svn_Content from [Svn_Product] ";
OleDbConnection conn = new OleDbConnection(connectionString);
OleDbDataAdapt ......
我想用C#实现象ASP中的
rs.addnew
rs( "a ") = "aaa "
rs( "b ") = 123
rs.update
这样方法添加数据,问一下,要怎么做啊?
具体方法如下
string dbPath = "../App_data/WebSeven.mdb ";
string db = Server.MapPath(dbPath);
string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " + db;
string strSQL = "SELECT [Svn_title],Svn_Content from [Svn_Product] ";
OleDbConnection conn = new OleDbConnection(connectionString);
OleDbDataAdapt ......
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
namespace WA.IBMS.FindTreeNode //lxh 2008-9-16
{
/// <summary>
///SelectTreeNode 的摘要说明
/// </summary>
public class SelectTreeNode
{
public SelectTreeNode()
{
//
//TODO: 在此处添加构造函数逻辑
//
}
/// ......
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
namespace WA.IBMS.FindTreeNode //lxh 2008-9-16
{
/// <summary>
///SelectTreeNode 的摘要说明
/// </summary>
public class SelectTreeNode
{
public SelectTreeNode()
{
//
//TODO: 在此处添加构造函数逻辑
//
}
/// ......
JS:
//获取元素指定tagName的父元素 lxh 2009 03 10
function public_GetParentByTagName(element, tagName)
{
var parent = element.parentNode;
var upperTagName = tagName.toUpperCase();
while (parent && (parent.tagName.toUpperCase() != upperTagName))
{
parent = parent.parentNode ? parent.parentNode : parent.parentElement;
}
return parent;
}
//设置节点的父节点Cheched——该节点可访问,则他的父节点也必能访问
function setParentChecked(objNode)
{
var objParentDiv = public_GetParentByTagName(objNode,"div");
if(objParentDiv==null || objParentDiv == "undefined")
{
return;
}
var objID = objParentDiv.getAttribute("ID");
objID = objID.substr ......
public void Gridview_BindNoRecords(GridView gridView, DataTable dt) // gridView,绑定数据源DT
{
int a = dt.Rows.Count;
if (dt.Rows.Count == 0)
{
dt.Rows.Add(dt.NewRow());
gridView.DataSource = dt;
gridView.DataBind();
int columnCount = gridView.Rows[0].Cells.Count;
gridView.Rows[0].Cells.Clear();
gridView.Rows[0].Cells.Add(new TableCell());
gridView.Rows[0].C ......