难点与不同点,ASP链接MSSQL2005的链接字符串
ASP链接MSSQL2005的链接字符串如下:
测试用例如下:(ASP链接MSSQL2005测试)
<%
Option Explicit
Dim conn,rs,sql
Set conn = CreateObject(“ADODB.Connection”)
Dim strConn ‘MSSQL 2005 Connection String
strConn = “Provider=SQLNCLI;Server=.\SQLEXPRESS;Database=master;Uid=xeonwell;Pwd=xxxx;”
conn.Open strConn
Set rs = conn.Execute(“select * from spt_values”)
Dim i,j
j = rs.fields.count-1
Response.Write(“<table border=1>”)
Response.Write(“<tr>”)
for i = 0 to j
Response.Write(“<th>” & rs.fields(i).name & “</th>”)
next
Response.Write(“</tr>”)
While Not rs.EOF
‘ Response.Write(rs.fields(0).Name & “: ” & rs.Fields(0).Value & “<br />”)
Response.Write(“<tr>”)
for i = 0 to j
Response.Write(“<td>” & replaceNull(rs.fields(i).value) & “</td>”)
next
Response.Write(“</tr>”)
rs.MoveNext()
Wend
Response.Write(“</table>”)
rs.Close()
Set rs = Nothing
conn.Close()
Set conn = Nothing
Function replaceNull(str)
replaceNull = str
If isNull(str) OR str = “” Then
replaceNull = “ ”
End If
End Function
%>
连接奇文小说程序可以用。