Greetings all,
I have run into a confusing issue with an ASP page that is trying to execute an SQL statement on a MySQL database.
Here is the code first:
Basically, the database connector (dbConn) is retrieved via the included retrieve_db.asp file. I have put some formatting in here to try and track the problem. All this page is supposed to do is insert a record into a table called menu then return the user to the management screen.
However, anytime the database connector is directly referenced, the system spits out an "object required" error. What makes it confusing is that using the same object to open a recordset is no problem at all.
Here is a printout of the results:
Any help on this issue would be greatly appreciated. I have used this way of doing things in the past without a problem connecting to a remote Oracle database so I can't figure what is wrong. Even declaring a new database connector within this code fails to do anything. I've even tried using the database admin account to login (which has no problems using the remote admin tool).
I have run into a confusing issue with an ASP page that is trying to execute an SQL statement on a MySQL database.
Here is the code first:
Code:
<!-- #include file="../functions.asp" -->
<!-- #include file="../retrieve_db.asp" -->
<%
on error resume next
Dim strSQL
Dim intParentID
Dim strDisplay
Dim strMenuType
Dim strURL
Dim intDisplayOrder
Dim recTest
Set recTest = Server.CreateObject("ADODB.Recordset")
intParentID = Request.Form("parent_id")
strDisplay = Request.Form("display")
strMenuType = Request.Form("menu_type")
strURL = Request.Form("url")
intDisplayOrder = Request.Form("display_order")
strDisplay = Replace(strDisplay, "'","''")
Response.Write("<b>SQL Statement</b><br>")
strSQL = "INSERT INTO menu (display, menu_type, url, display_order, parent_id) " & _
"VALUES ('" & strDisplay & "', " & _
"'" & strMenuType & "', " & _
"'" & strURL & "', " & _
intDisplayOrder & ", " & _
intParentID & ");"
Response.Write(strSQL & "<br>")
Response.Write("<br><b>Return Connection String</b><br>")
Response.Write(dbConn.ConnectionString & "<br>")
if err.number <> 0 Then
Response.Write("1: " & err.number & " - " & err.description & "<br>")
End If
err.number = 0
Response.Write("<br><b>Execute SQL</b><br>")
dbConn.Execute strSQL
if err.number <> 0 Then
Response.Write("2: " & err.number & " - " & err.description & "<br>")
End If
err.number = 0
Response.Write("<br><b>Folder Structure</b><br>")
strSQL = "SELECT * FROM menu"
With recTest
.Open strSQL, dbConn
If Not .EOF Then
.MoveFirst
While Not .EOF
Response.Write(.Fields("display").Value & "<br>")
.MoveNext
Wend
End If
.Close
End With
if err.number <> 0 Then
Response.Write("2: " & err.number & " - " & err.description & "<br>")
End If
' Response.Redirect("manage_menu.asp")
%>
Basically, the database connector (dbConn) is retrieved via the included retrieve_db.asp file. I have put some formatting in here to try and track the problem. All this page is supposed to do is insert a record into a table called menu then return the user to the management screen.
However, anytime the database connector is directly referenced, the system spits out an "object required" error. What makes it confusing is that using the same object to open a recordset is no problem at all.
Here is a printout of the results:
Code:
SQL Statement
INSERT INTO menu (display, menu_type, url, display_order, parent_id) VALUES ('Navy', 'm', 'XX', 1, 1);
Return Connection String
1: 424 - Object required
Execute SQL
2: 424 - Object required
Folder Structure
Admin
Menu
Any help on this issue would be greatly appreciated. I have used this way of doing things in the past without a problem connecting to a remote Oracle database so I can't figure what is wrong. Even declaring a new database connector within this code fails to do anything. I've even tried using the database admin account to login (which has no problems using the remote admin tool).