2012-11-28 102 views
2

嘿我試圖讓我的SQL Server版本10.50.2500連接在經典ASP經典ASP連接到SQL Express服務器500服務器錯誤

我在.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的情況下生效 - 顯示內部服務器錯誤

我還有什麼可以嘗試才能使其工作?

回答

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 
+0

我改正了,但仍然有500錯誤。 – StealthRT

+0

@stealth我已編輯我的帖子,添加一些調試。 – SearchAndResQ

+0

感謝您的信息。我相信它必須處理未正確配置的服務器,以便連接到數據庫服務器。 – StealthRT

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) 
+0

由於頁面爲500,我不會看到任何東西。 – StealthRT

+0

註釋執行行並查看您的SQL。如果您使用IE,請進入設置並關閉「友好的http錯誤消息」。 –

+0

查詢很好。但是,它在** set objRS = objConn.execute(strSQL)**行上崩潰。 – StealthRT