HELP!!! MySQL Connection

S

Steven

I first have to be honest. I am new to ASP.NET 2 (well, ASP in
general). I have mostly PHP background. So please try to keep any
responses somewhat simple.

First of all, on my XP machine. I have IIS installed, using a Virtual
Directory for my site, and I have set it to use ASP.NET version
2.0.50727. I also have MySQL version 4.0.20 running. I have also
installed MySQL Connector/ODBC 3.51 and MySQL Connector NET 5.0.6.

OK.. First of all what else do I need to get connected? Second of all
HOW do I connect? I have seen a tons of complexed ways and none of
them make any scene or work.

I have also seen something about .NET 2 not using record sets.
Everyone keeps putting the data in a datagrid. I don't get it.

Last but not least. The site will be hosted at GoDaddy.com. They have
a sample connection script that looks like this:

------------------------------------------------------------------------------------------------------------------------------------

<%
Dim oConn, oRs
Dim qry, connectstr, sDSNDir
Dim db_name, db_username, db_userpassword
Dim db_server, dsn_name

dsn_name = "your_dsn_name"
fieldname = "your_fieldname"
tablename = "your_tablename"

sDSNDir = Server.MapPath("_dsn")

connectstr = "filedsn=" & sDSNDir & "" & dsn_name

Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open connectstr
qry = "SELECT * FROM " & tablename

Set oRS = oConn.Execute(qry)

if not oRS.EOF then
while not oRS.EOF
response.write ucase(fieldname) & ": " & oRs.Fields(fieldname) & "
"
oRS.movenext
wend
oRS.close
end if

Set oRs = nothing
Set oConn = nothing

%>

------------------------------------------------------------------------------------------------------------------------------------

It seems to be missing somethings, like where to put the user name and
password. And what is this Server.MapPath("_dsn") ?

Please help.. I have been trying over two weeks trying to figure this
out..

Thank you VERY much in advance.
 
M

Mark Rae

I have also installed MySQL Connector/ODBC 3.51 and MySQL Connector NET
5.0.6.

There is absolutely no reason to use anything other than the native .NET
data provider - you can safely delete the ODBC driver.
OK.. First of all what else do I need to get connected? Second of all
HOW do I connect? I have seen a tons of complexed ways and none of
them make any scene or work.
http://dev.mysql.com/tech-resources/articles/dotnet/#ADO.NET
http://www.connectionstrings.com/?carrier=mysql

I have also seen something about .NET 2 not using record sets.
Everyone keeps putting the data in a datagrid. I don't get it.

By default, .NET doesn't use ADO - it uses ADO.NET. ADO.NET doesn't use
RecordSets - it uses DataSets.
Last but not least. The site will be hosted at GoDaddy.com.

Oh dear - is it too late to cancel...? I've heard nothing by horror stories
from people who host with them...
 
G

Guest

I first have to be honest. I am new to ASP.NET 2 (well, ASP in
general). I have mostly PHP background. So please try to keep any
responses somewhat simple.

First of all, on my XP machine. I have IIS installed, using a Virtual
Directory for my site, and I have set it to use ASP.NET version
2.0.50727. I also have MySQL version 4.0.20 running. I have also
installed MySQL Connector/ODBC 3.51 and MySQL Connector NET 5.0.6.

OK.. First of all what else do I need to get connected? Second of all
HOW do I connect? I have seen a tons of complexed ways and none of
them make any scene or work.

I have also seen something about .NET 2 not using record sets.
Everyone keeps putting the data in a datagrid. I don't get it.

Last but not least. The site will be hosted at GoDaddy.com. They have
a sample connection script that looks like this:

---------------------------------------------------------------------------­---------------------------------------------------------

<%
Dim oConn, oRs
Dim qry, connectstr, sDSNDir
Dim db_name, db_username, db_userpassword
Dim db_server, dsn_name

dsn_name = "your_dsn_name"
fieldname = "your_fieldname"
tablename = "your_tablename"

sDSNDir = Server.MapPath("_dsn")

connectstr = "filedsn=" & sDSNDir & "" & dsn_name

Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open connectstr
qry = "SELECT * FROM " & tablename

Set oRS = oConn.Execute(qry)

if not oRS.EOF then
while not oRS.EOF
response.write ucase(fieldname) & ": " & oRs.Fields(fieldname) & "
"
oRS.movenext
wend
oRS.close
end if

Set oRs = nothing
Set oConn = nothing

%>

---------------------------------------------------------------------------­---------------------------------------------------------

It seems to be missing somethings, like where to put the user name and
password. And what is this Server.MapPath("_dsn") ?

Please help.. I have been trying over two weeks trying to figure this
out..

Thank you VERY much in advance.

This is a code in ASP, not ASP.NET. It used a DSN connection (I think,
it's valid for default GoDaddy settings) and this is a reason why
there no username and password was specified.

Look at this tutorial: http://www.15seconds.com/issue/050210.htm

Find more: http://www.google.com/search?hl=en&q=asp.net+mysql
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top