| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1204 人关注过本帖, 1 人收藏
标题:asp连接数据库SQLserver2000代码谁给发过来谢谢
只看楼主 加入收藏
chengmingfei
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2008-3-14
收藏(1)
 问题点数:0 回复次数:4 
asp连接数据库SQLserver2000代码谁给发过来谢谢
我是新手.急不可待.谢谢在线等
搜索更多相关主题的帖子: 数据库 asp 代码 急不可待 
2008-05-20 10:30
chengmingfei
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2008-3-14
收藏
得分:0 
2. ASP与SQL数据库连接:

<%
dim conn
set conn=server.createobject("ADODB.connection")
con.open "PROVIDER=SQLOLEDB;DATA SOURCE=SQL服务器名称或IP地址;UID=sa;PWD=数据库密码;DATABASE=数据库名称
%>

建立记录集对象:

set rs=server.createobject("adodb.recordset")
rs.open SQL语句,conn,3,2
2008-05-20 10:36
woo23778206
Rank: 1
等 级:新手上路
帖 子:40
专家分:0
注 册:2007-10-31
收藏
得分:0 
看了几个帖子,也是因为sql的数据库连接不上,可是在看看别人的发的帖子,都几十个月了,回复的人还不到10个,真不知道高手在哪里,版主是干什么吃的啊,郁闷,去别的地方吧,我在csdn发的贴,虽然还没有解决问题,但至少是有人给回复的啊!
2008-11-22 14:53
dhdhzzw
Rank: 1
等 级:新手上路
帖 子:949
专家分:0
注 册:2007-8-13
收藏
得分:0 
这种问题解决方案百度一搜一大堆,可能是这个原因,没人回答你,CSDN我也去过80%是垃圾回帖,还不如这里呢。/
2008-11-25 14:06
towering
Rank: 7Rank: 7Rank: 7
等 级:黑侠
威 望:1
帖 子:261
专家分:507
注 册:2007-10-9
收藏
得分:0 
这个是我的conn文件,
是仿DVbbs的,
楼主拿去用吧。

<%
'防止SQL注入
dim urlnlu
urlnlu=LCase(Request.ServerVariables("QUERY_STRING"))
if instr(urlnlu,"select")>0 OR instr(urlnlu,"'")>0 OR instr(urlnlu,"mid")>0 OR instr(urlnlu,"master")>0 OR instr(urlnlu,"truncate")>0 OR instr(urlnlu,"declare")>0 OR instr(urlnlu,"between")>0 OR instr(urlnlu,"exec")>0 or instr(urlnlu,"where")>0 OR instr(urlnlu,"and")>0 OR instr(urlnlu,"not")>0 OR instr(urlnlu,"from")>0 OR instr(urlnlu,"sum")>0 OR instr(urlnlu,"avg")>0 OR instr(urlnlu,"max")>0 OR instr(urlnlu,"min")>0 OR instr(urlnlu,"delete")>0 OR instr(urlnlu,"insert")>0 OR instr(urlnlu,"table")>0 OR instr(urlnlu,"update")>0 OR instr(urlnlu,";")>0 OR instr(urlnlu,"<>")>0 OR instr(urlnlu,">")>0 OR instr(urlnlu,"<")>0 OR instr(urlnlu,"|")>0 OR instr(urlnlu,"top")>0 OR instr(urlnlu,">=")>0 OR instr(urlnlu,"<=")>0 OR instr(urlnlu,"%")>0 OR instr(urlnlu,"len")>0 OR instr(urlnlu,"chr")>0 OR instr(urlnlu,"backup")>0  OR instr(urlnlu,"+")>0 OR instr(urlnlu,"'")>0 OR instr(urlnlu,")")>0 OR instr(urlnlu,"(")>0 OR instr(urlnlu,"*")>0 OR instr(urlnlu,",")>0 OR instr(urlnlu,chr(32))>0 then
response.Write("请勿手动修改URL参数!")
response.end
end if


'数据库连接开始
Dim conn, MM_conn_STRING

'定义数据库类别,1为SQL数据库,0为Access数据库
Const IsSqlDataBase=1

If IsSqlDataBase=1 Then

'sql数据库连接参数:数据库名、用户密码、用户名、连接名(本地用local,外地用IP)
Dim SqlDatabaseName,SqlPassword,SqlUsername,SqlLocalName
SqlDatabaseName="你的数据库名"
SqlPassword="密码"
SqlUsername="用户名"
SqlLocalName="(local)"

MM_conn_STRING = "Provider=Sqloledb; User ID=" & SqlUsername & "; Password=" & SqlPassword & "; Initial Catalog = " & SqlDatabaseName & "; Data Source=" & SqlLocalName & ";"

Else
Dim Db
Db="data/data.mdb"

MM_conn_STRING = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(Db)
End If

On Error Resume Next
Set conn = Server.CreateObject("ADODB.Connection")
conn.open MM_conn_STRING

If Err Then
err.Clear
Set conn = Nothing
Response.Write "Database connection error, please check the connection string."
Response.End()
End If
%>
2008-11-25 16:35
快速回复:asp连接数据库SQLserver2000代码谁给发过来谢谢
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012530 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved