日期:2014-05-17  浏览次数:20898 次

asp连接sql
公司网站做好了,要上传到网上,以前我用是access,现在空间是用sql的,下面这些代码该怎么写。。。
<%
set   conn=server.createobject( "adodb.connection ")
conn.open   "provider=microsoft.jet.oledb.4.0;data   source= "&   server.mappath( "\bondrise\database\admin.mdb ")

%>
  <%  
set   rs=server.createobject( "ADODB.Recordset ")  
sql= "select   top   10   *   from   news   order   by   id   desc "  
rs.open   sql,conn,1,1
do   while   not   rs.eof
response.write " <a   href= 'newcenter.asp?id= "   &   rs( "id ")   &   " '   target= '_blank '> "   &   rs     ( "content ")   &   " </a> <br> ------------------------------------------------ <br> "

rs.movenext
loop        
%>

------解决方案--------------------
dim conn
dim connstr
dim db
Set conn = Server.CreateObject( "ADODB.Connection ")
connstr= "driver={SQL Server};server=(local);database=bus;uid=sa;pwd=sa; "
conn.Open connstr
If Err Then
Err.Clear
Set conn = Nothing
Response.Write "数据库连接文件出错,请联系管理员。 "
Response.End
End If