MySQL Forums
Forum List  »  Connector/ODBC

Connecting to a MySQL DB with ASP using ADODB.Command Problem
Posted by: Ramiro Maldonado
Date: December 13, 2007 03:13PM

Hi:

I'm relatively new in web programming. I´ve developed a web application connected to a MySQL database, using ASP VBScript and Dreamweaver CS3 as development tool.

I have no problems with the site running on my testing server (locally).

The problem appears when i upload the site to the host, specifically when i execute the web application from the remote server and it wants to comunicate with the database hosted in the remote MySQL server, the app returns me an error message that follows:

"Microsoft OLE DB Provider for ODBC Drivers error '80040e31'

[MySQL][ODBC 3.51 Driver][mysqld-5.0.20a-community]SELECT command denied to user 'usuario'@'localhost' for table 'usuarios'

/sections/login/login.asp, line 20"

In this case the line 20 holds the Execute of the Command object (you can see the code at the end of the post).

At the beginning i though that there was some kind of error with the permission assigned to the user 'usuario' to interact with the DB, so i requested assistance to the hosting support team.

The response they gave me is that the user 'usuario' has root privileges to access the databases created from the dpanel of the site and that there were no inconveniences to comunicate with the database. Even, they´ve uploaded an example page to the site that succesfully connected to my database.

When i´ve opened that page to review the connection code, i could see that the ADO method to connect to the DB was made through the creation of an ADODB.Recordset object.

And here relies the problem: The ADO method that Dreamweaver CS3 uses to generate all the connection code to comunicate with the DB is through the creation of ADODB.Command objects.

To reject others issues as eventual causes of the problem, i replaced in one of my pages that interacts with the DB the ADODB.Command method with the ADODB.Recordset method, then uploaded the page to the remote server and checked that the connection was made succesfully.

With that check passed, i newly made contact with the support team of the host provider requesting an explanation about these connection problem using the ADODB.Command method, but i still haven´t get an answer from them yet.

Well... i´ve been searching along the web for an answer to this problem with no success.

Perhaps the solution it's a silly issue to someone with advanced knowledge, but to me it's a really pain in the ... So please, if somebody came give me a hand, i'll be really pleased!

Thanks.

PD: I'm including next the page code to better reference:


<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
Dim ConnSquashchaco
Set ConnSquashchaco = Server.CreateObject("ADODB.Connection")
ConnSquashchaco.Open "Driver={MySQL ODBC 3.51 Driver}; " & _
"Server=localhost; " & _
"Database=database; " & _
"UID=usuario; " & _
"PWD=password"
%>
<%
Dim rsUsuarios
Dim rsUsuarios_cmd
Dim rsUsuarios_numRows

Set rsUsuarios_cmd = Server.CreateObject ("ADODB.Command")
rsUsuarios_cmd.ActiveConnection = ConnSquashchaco
rsUsuarios_cmd.CommandText = "SELECT nombreusuario FROM squashchaco.usuarios"
rsUsuarios_cmd.Prepared = true
Set rsUsuarios = rsUsuarios_cmd.Execute
rsUsuarios_numRows = 0
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">;
<html xmlns="http://www.w3.org/1999/xhtml">;
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<%
While Not rsUsuarios.EOF
response.write rsUsuarios.fields(1).value
rsUsuarios.MoveNext
Wend
%>
</body>

</html>
<%
rsUsuarios.Close()
Set rsUsuarios = Nothing
%>

Options: ReplyQuote


Subject
Written By
Posted
Connecting to a MySQL DB with ASP using ADODB.Command Problem
December 13, 2007 03:13PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.