【问题标题】:CLASSIC asp connecting to SQL Express Server 500 server errorCLASSIC asp 连接到 SQL Express Server 500 服务器错误
【发布时间】:2012-11-28 20:57:42
【问题描述】:

大家好,我正在尝试在 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 - 内部服务器错误。 而不是一个有帮助的错误!

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

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

【问题讨论】:

    标签: database asp-classic adodb recordset


    【解决方案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
    

    【讨论】:

    • 感谢您的帖子。我认为这与未正确配置服务器有关,以便它连接到数据库服务器。
    【解决方案2】:

    试试:

    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)
    

    【讨论】:

    • 由于页面为 500,我看不到任何内容。
    • 注释掉执行行并查看您的 SQL。如果您使用的是 IE,请进入设置并关闭“友好的 http 错误消息”。
    • 查询很好。但是,它在 set objRS = objConn.execute(strSQL) 行上崩溃。
    • 直接将查询粘贴到MS SQL查询窗口中,看是实际执行还是失败。
    • 我在 SQL 管理器中运行时得到 (0 行受影响)。没有错误。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-06-02
    • 1970-01-01
    • 1970-01-01
    • 2022-01-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多