展开全部
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
dim DataLinkType,conn,connstr,MyDbPath
MyDbPath="/inc/datas.mdb" '数据库文件位置
DataLinkType = 0 '设置数据库连接方式,1为SQL数据库,0为Access数据库
If dataLinkType=0 Then
'**************************************************
'使用Access数据库
'**************************************************
ConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(MyDbPath)
Else
'**************************************************
'使用SQL数据库
'**************************************************
'ConnStr = "Driver={SQL Server}; server=(local);uid=sa;pwd=windows;database=data1;"
ConnStr = "Provider=SQLNCLI; server=.\SQLEXPRESS;uid=sa;pwd=windows;database=data1;"
End If
On Error Resume Next
Set conn = Server.CreateObject("ADODB.Connection")
conn.open ConnStr
If Err Then
Err.Clear
Set Conn = Nothing
Response.Write "数据库连接出错,请检查连接字串。"'注释,需要把这几个字翻译成英文。
Response.End
End If
'**************************************************
'关闭数据库
'**************************************************
sub CloseConn()
conn.close
set conn=nothing
end Sub
Dim id
if Replace(Replace(request.QueryString("id"),"or",""),"'","")="" Or IsNull(Replace(Replace(request.QueryString("id"),"or",""),"'","")) Then
response.write "传值错误!!!"
response.End()
Else
id=Replace(Replace(request.QueryString("id"),"or",""),"'","")
sql="insert into 表名([字段名]])values('"+id+"')"
Conn.Execute sql
response.write "保存成功!!!"
End if
%>
<%
dim DataLinkType,conn,connstr,MyDbPath
MyDbPath="/inc/datas.mdb" '数据库文件位置
DataLinkType = 0 '设置数据库连接方式,1为SQL数据库,0为Access数据库
If dataLinkType=0 Then
'**************************************************
'使用Access数据库
'**************************************************
ConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(MyDbPath)
Else
'**************************************************
'使用SQL数据库
'**************************************************
'ConnStr = "Driver={SQL Server}; server=(local);uid=sa;pwd=windows;database=data1;"
ConnStr = "Provider=SQLNCLI; server=.\SQLEXPRESS;uid=sa;pwd=windows;database=data1;"
End If
On Error Resume Next
Set conn = Server.CreateObject("ADODB.Connection")
conn.open ConnStr
If Err Then
Err.Clear
Set Conn = Nothing
Response.Write "数据库连接出错,请检查连接字串。"'注释,需要把这几个字翻译成英文。
Response.End
End If
'**************************************************
'关闭数据库
'**************************************************
sub CloseConn()
conn.close
set conn=nothing
end Sub
Dim id
if Replace(Replace(request.QueryString("id"),"or",""),"'","")="" Or IsNull(Replace(Replace(request.QueryString("id"),"or",""),"'","")) Then
response.write "传值错误!!!"
response.End()
Else
id=Replace(Replace(request.QueryString("id"),"or",""),"'","")
sql="insert into 表名([字段名]])values('"+id+"')"
Conn.Execute sql
response.write "保存成功!!!"
End if
%>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询