淘主机 发表于 2008-5-18 19:41:43

使用ASP/ADO链接Godaddy的MSSQL数据库的代码

相关文章阅读:

Godaddy主机建立MSSQL数据库方法
Godaddy主机导入MSSQL数据库教程
Godaddy主机如何导出MSSQL数据库
Godaddy主机Access数据库的设置方法


ASP/ADO链接Godaddy的MSSQL数据库的代码如下,供大家参考:
<%

'Sample Database Connection Syntax for ASP and SQL Server.

Dim oConn, oRs
Dim qry, connectstr
Dim db_name, db_username, db_userpassword
Dim db_server

db_server = "whsql01.mesa1.secureserver.net"
db_name = "your_dbname"
db_username = "your_dbusername"
db_userpassword = "your_dbpassword"
fieldname = "your_field"
tablename = "your_table"

c & db_server & ";DATABASE=" & db_name & ";UID=" & db_username & "WD=" & db_userpassword

Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open connectstr

qry = "SELECT * FROM " & tablename

Set oRS = oConn.Execute(qry)

Do until oRs.EOF
   Response.Write ucase(fieldname) & ": " & oRs.Fields(fieldname)
   oRS.MoveNext
Loop
oRs.Close


Set oRs = nothing
Set oConn = nothing

%>
页: [1]
查看完整版本: 使用ASP/ADO链接Godaddy的MSSQL数据库的代码