CLASSIC asp连接到SQL Express Server 500服务器错误

时间:2012-11-28 20:57:42

标签: database asp-classic adodb recordset

嘿所有我想在经典ASP

中连接到我的SQL Server版本10.50.2500

.asp页面中的代码是(包括我尝试过的所有连接字符串):

Set objConn = Server.CreateObject("ADODB.Connection")
Set objRS   = Server.CreateObject("ADODB.Recordset")

'objConn.ConnectionString = "Provider={SQL Server};Server=xxx.xxx.xxx.xxx\SQLEXPRESS;Database=JForm;User ID=xxxx;Pwd=xxxx"
'objConn.ConnectionString = "Driver={SQL Server};Server=xxx.xxx.xxx.xxx\SQLEXPRESS;Database=JForm;Uid=xxxx;Pwd=xxxx;"
'objConn.ConnectionString = "Provider=SQLNCLI10;Server=xxx.xxx.xxx.xxx,1433;Database=JForm;Uid=xxxx;Pwd=xxxx;Persist Security Info=True"
'objConn.ConnectionString = "Provider=SQLNCLI;Server=.\SQLEXPRESS;Database=JForm;Uid=xxxx;Pwd=xxxx"
objConn.ConnectionString = "Driver={SQL Server Native Client 10.0};Server=xxx.xxx.xxx.xxx\SQLEXPRESS;Database=JForm;Uid=xxxx;Pwd=xxxx"

strSQL = "UPDATE jURLS " & _
        "SET rssFeedURL = 'http://www.xxxx.com/rss/" & rss & "'," & _
        "csvURL = 'http://www.xxxx.com/csv/" & csv & "'," & _
        "jFormName = '" & forname & "'," & _
        "isActive = " & active & " " & _
        "WHERE jFormName = '" & forname & "'"

objConn.open
objRS.Open strSQL, objConn, 1,3

'If Not objRS.EOF Then
 'iterate through records here
'Else
 'no records found
'End If

objRS.close
Set objRS=Nothing
objConn.close
Set objConn=Nothing

似乎在 objConn.open 上崩溃了。但是,它只给我一个 500 - 内部服务器错误。而不是一个有用的错误!

一旦我从页面中获取数据库代码并保留其他所有内容,它就可以在不显示 500 - 内部服务器错误的情况下工作。

我还能尝试什么才能让它发挥作用?

2 个答案:

答案 0 :(得分:1)

这里有一个额外的逗号:

"isActive = " & active & "," & _

将其更改为:

"isActive = " & active & " " & _

关于连接错误try debugging using the connection.errors collection

On Error Resume Next
objConn.open

for each errobj in objConn.Errors
    Response.write errobj.Number & "<br />"
    Response.write errobj.Description & "<br />"
next

On Error Goto 0

答案 1 :(得分:0)

尝试:

response.write(strSQL) <-- this will allow you to look at your current SQL statement and see if it makes sense.
set objRS = objConn.execute(strSQL)