Forum Moderators: open

Message Too Old, No Replies

connection to mysql db using asp

         

marena23

3:41 pm on Jan 22, 2004 (gmt 0)

10+ Year Member



hello all,
i'm trying to connect to a mysql database using a dsn-less connection via asp but keep getting the following error:

"Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

/mysqltest.asp, line 6"

the error is generated from the following code:
"<%
dim adoConn
dim adoRS
set adoConn = Server.CreateObject("ADODB.Connection")
set adoRS = Server.CreateObject("ADODB.Recordset")
adoConn.Open "Driver={MySQL ODBC 3.51 Driver}; Server=192.168.1.117; Port=3306; Option=0; Socket=; Stmt=; Database=dot; Uid=user; Pwd=password;"
adoRS.ActiveConnection = adoConn
if adoConn.errors.count = 0 then
adoRS.Open "select * from log"
end if
adoRS.Close
adoConn.Close
Set adoRS = nothing
Set adoConn = nothing
%>"

anyone know what's wrong with this?

thanks in advance,
Mike

txbakers

6:12 pm on Jan 22, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you don't have a user name and password set you don't need to include that in the string.

Otherwise I don't see anything offensive in it.

gelnd

6:38 pm on Jan 22, 2004 (gmt 0)

10+ Year Member



Looks like it is your driver value.

Instead of: Driver={MySQL ODBC 3.51 Driver};
Try: Driver={MySQL};

mattglet

6:59 pm on Jan 22, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



i also use mySQL with asp, and here's my connection string:

conn_string = "driver={MySQL ODBC 3.51 Driver};server=serverip;uid=username;pwd=password;database=databasename;"
set conn = server.CreateObject("adodb.connection")

conn.open(conn_string)

-Matt

marena23

8:50 pm on Jan 22, 2004 (gmt 0)

10+ Year Member



still cannot get it to work without the DSN..its giving me that same error..here's what i changed the code to:

<%@ LANGUAGE="VBSCRIPT" %>
<%
dim conn

conn_string = "Driver={MySQL};Server=192.168.1.166;Port=3306;Option=131072;Stmt=;Database=db;Uid=monty;Pwd=password"

Set conn = Server.CreateObject("ADODB.Connection")

conn.Open(conn_string)

strQuery = "SELECT * FROM log;"
Set RS = adoDataConn.Execute(strQuery)

%>

<html>
<head>
<title>this is the results page</title>
</head.

<body>
<b>This is the result set</b>
<br>
<%while not RS.eof%>
<%=RS("ip")%>&nbsp;&nbsp;<%=RS("referer")%><br>
<%RS.MoveNext%>
<%wend%>

<%
RS.Close
conn.Close
%>

</body>
</html>

mattglet

10:19 pm on Jan 22, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



note my changes:

<%@ LANGUAGE="VBSCRIPT" %>
<%
dim conn
dim conn_string

conn_string = "Driver={MySQL};Server=192.168.1.166;Port=3306;Database=db;Uid=monty;Pwd=password"

Set conn = Server.CreateObject("ADODB.Connection")

conn.Open(conn_string)

strQuery = "SELECT * FROM log;"
Set RS = conn.Execute(strQuery)

%>

<html>
<head>
<title>this is the results page</title>
</head.

<body>
<b>This is the result set</b>
<br>
<%while not RS.eof%>
<%=RS("ip")%>&nbsp;&nbsp;<%=RS("referer")%><br>
<%RS.MoveNext%>
<%wend%>

<%
set rs = nothing
RS.Close
conn.Close
%>

</body>
</html>

marena23

2:16 pm on Jan 23, 2004 (gmt 0)

10+ Year Member



still not working..when I run your script Matt I get the following error:

"Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
/test3.asp, line 10"

test3.asp contains the exact source from above

any other ideas?

thanks for all your help,
Mike

defanjos

5:08 pm on Jan 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have just started using MySQL on a windows server and I don't need to use the IP address because the DB is in the same server (I use localhost). I remember reading that if you are going to use the IP address, you have to grant privileges to the user. I wonder if this is your problem.

MySQL site [mysql.com]

After you grant privileges, don't forget to try "Driver={MySQL ODBC 3.51 Driver};", I think that is the correct way.

mattglet

10:42 pm on Jan 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



sorry, i totally didn't see that you had your driver listed as {MYSQL}. it NEEDS to be {MySQL ODBC 3.51 Driver}.

and you could be right defanjos. you might need special privledges for using IP. i always use localhost as well.

-Matt

gelnd

9:39 pm on Jan 26, 2004 (gmt 0)

10+ Year Member



Do you even have a driver installed? Go to your ODBC connections in your administrative tools (on windows 2000 and xp at least) and check if you have a MySql driver and what version it is.

marena23

2:18 pm on Jan 27, 2004 (gmt 0)

10+ Year Member



I'm using win2000 and I just checked and the driver "MySQL ODBC 3.51 Driver" is installed under the "System DSN" tab. Can't understand why this is still giving the following error "Data source name not found and no default driver specified".

Are there any permissions in IIS that could prevent the use of DSN's?

thanks for everyone's continued help,
Mike

defanjos

3:19 pm on Jan 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



marena23,

If you have not done so, I would read the MySQL windows installation documentation [mysql.com] very carefully, before proceeding.