请选择 进入手机版 | 继续访问电脑版

godaddy 优惠码

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 4002|回复: 12

asp+mssql的连接方式   [复制链接]

Rank: 2

UID
392
阅读权限
20
积分
67
金钱
139
威望
0
登录
15 天
发表于 2011-11-6 21:35:58 |显示全部楼层
求助godaddy空间asp+mssql的连接方式,请注意,是asp不是net的,网上找了很多代码都不行,特来此求助
分享到:
Disclosure:We are a professional review site that receives compensation from the companies whose products we review. We test each product thoroughly and give high marks to only the very best. We are independently owned and the opinions expressed here are our own.

Rank: 9Rank: 9Rank: 9

UID
2
阅读权限
200
积分
6749
金钱
15921
威望
60
登录
1733 天
发表于 2011-11-7 08:35:40 |显示全部楼层
This example describes using ASP/ADO to connect to a Microsoft SQL Server Database.
下面是一个使用asp/ado链接MS SQL的例子:
  1. <%

  2. 'Sample Database Connection Syntax for ASP and SQL Server.

  3. Dim oConn, oRs
  4. Dim qry, connectstr
  5. Dim db_name, db_username, db_userpassword
  6. Dim db_server

  7. db_server = "whsql01.mesa1.secureserver.net"
  8. db_name = "your_dbname"
  9. db_username = "your_dbusername"
  10. db_userpassword = "your_dbpassword"
  11. fieldname = "your_field"
  12. tablename = "your_table"

  13. connectstr = "Driver={SQL Server};SERVER=" & db_server & ";DATABASE=" & db_name & ";UID=" & db_username & ";PWD=" & db_userpassword

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

  16. qry = "SELECT * FROM " & tablename

  17. Set oRS = oConn.Execute(qry)

  18. Do until oRs.EOF
  19.    Response.Write ucase(fieldname) & ": " & oRs.Fields(fieldname)
  20.    oRS.MoveNext
  21. Loop
  22. oRs.Close


  23. Set oRs = nothing
  24. Set oConn = nothing

  25. %>
复制代码

Rank: 2

UID
392
阅读权限
20
积分
67
金钱
139
威望
0
登录
15 天
发表于 2011-11-17 15:39:39 |显示全部楼层
qry = "INSERT INTO book (new) values('"&new&"')"
插入数据错误,求解

Rank: 1

UID
24957
阅读权限
10
积分
10
金钱
30
威望
0
登录
5 天
发表于 2014-4-22 15:29:28 |显示全部楼层

Rank: 7Rank: 7Rank: 7

UID
25137
阅读权限
40
积分
350
金钱
262
威望
0
登录
15 天
发表于 2014-4-26 19:52:29 |显示全部楼层

Rank: 11Rank: 11Rank: 11Rank: 11

UID
25229
阅读权限
50
积分
655
金钱
410
威望
0
登录
33 天
发表于 2014-5-7 01:03:08 |显示全部楼层
好东西啊,谢谢楼主啊!!











Rank: 11Rank: 11Rank: 11Rank: 11

UID
25405
阅读权限
50
积分
653
金钱
459
威望
0
登录
32 天
发表于 2014-5-10 20:36:34 |显示全部楼层
爱死你了,这么好的帖子要顶的











Rank: 11Rank: 11Rank: 11Rank: 11

UID
25405
阅读权限
50
积分
653
金钱
459
威望
0
登录
32 天
发表于 2014-5-11 10:26:04 |显示全部楼层
谢谢楼主啊,受益匪浅啊!











Rank: 11Rank: 11Rank: 11Rank: 11

UID
25405
阅读权限
50
积分
653
金钱
459
威望
0
登录
32 天
发表于 2014-5-12 22:08:04 |显示全部楼层
确实值得好好看看,顶先











Rank: 11Rank: 11Rank: 11Rank: 11

UID
25405
阅读权限
50
积分
653
金钱
459
威望
0
登录
32 天
发表于 2014-5-15 08:55:20 |显示全部楼层
謝謝,希望以後多些











您需要登录后才可以回帖 登录 | 注册

阿里云代金券
close
host1plus优惠码
close
vultr
digitalocean

Archiver|手机版|主机巴士论坛

GMT+8, 2018-7-23 17:57 , Processed in 0.046092 second(s), 15 queries .

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部