2

嘿,我正在尝试在Classic 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 - Internal server error。而不是一个有帮助的错误!

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

为了让它发挥作用,我还能尝试什么?

4

2 回答 2

1

你在这里有一个额外的逗号:

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

将其更改为:

"isActive = " & active & " " & _

关于连接错误,尝试使用 connection.errors 集合进行调试

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
于 2012-11-29T05:39:47.110 回答
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)
于 2012-11-28T21:16:21.257 回答