|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
need some help to connect ASP to mySQL... per "Using MyODBC" article suggestion...
Hello,
I am pretty new to ASP and I have a problem using it with mySQL. I am using ODBC on my Win 2000 server for ASP application. I have set up an ODBC driver (3.51) for mySQL and was able to create a local database. I am facing a rather interesting problem: I followed the instruction from a tutorial and set up a system DSN called personalweb. After verifying the connection, I continued on and created a sample ASP page to test it: <% on error resume next dim adoConn dim adoRS dim counter set adoConn = Server.CreateObject("ADODB.Connection") set adoRS = Server.CreateObject("ADODB.Recordset") adoConn.Open "DSN=personalweb" adoRS.ActiveConnection = adoConn if adoConn.errors.count = 0 then response.write "<h2>Fields In The 'ruser' Table:</h2>" adoRS.Open "describe ruser" while not adoRS.EOF response.write adoRS.fields(0).value & "<br>" adoRS.MoveNext wend else response.write "ERROR: Couldn't connect to database" end if %> Everything works, the columns were shown in the ASP page... Now, the problem is when I continued on and follow the second instruction in the tutorial and subsitute what I had with the following code: <% on error resume next dim adoConn dim adoRS dim counter set adoConn = Server.CreateObject("ADODB.Connection") set adoRS = Server.CreateObject("ADODB.Recordset") adoConn.Open "driver= {mysql};database=personalinfo;server=localhost;uid =adminbchiu;pwd=qwerty;" adoRS.ActiveConnection = adoConn if adoConn.errors.count = 0 then response.write "<h2>Fields In The 'ruser' Table:</h2>" adoRS.Open "describe ruser" while not adoRS.EOF response.write adoRS.fields(0).value & "<br>" adoRS.MoveNext wend else response.write "ERROR: Couldn't connect to database" end if %> The only thing I can get is the error message. I am wondering what I have done wrong... Please help. Thanks |
|
#2
|
||||
|
||||
|
What you've done is change the method used to connect you to the DB. Just use the DSN method and stick with it for now. Once you've got your head around ASP and DB connectivity, then you can mess around with other settings... for now, stick with what works.
Using DSN over another method won't restrict you in what you can and can't do with ASP. |
|
#3
|
|||
|
|||
|
thanks for the reply. However, I am trying to learn other methods that I can connect to the database. Obviously I understand I can stick with what works. However, it's essential for me to learn other methods so that later on I have an option to do so.
BTW, I seem to have fixed the problem myself though, by changing the driver to mysql ODBC 3.51 driver and uid to username, pwd to password and other things... so it works now. Thank you. |
|
#4
|
|||
|
|||
|
Two good links about connection strings. They doesn't explain so much, but if you are wondering how a connection string should be written, you will probably find it here:
http://www.connectionstrings.com/ http://www.able-consulting.com/ADO_Conn.htm |
|
#5
|
||||
|
||||
|
Ok - kewl - if you're learning, here's a few articles that tell you about DB connectivity... it's better to read articles about stuff that you're trying to learn, to figure out why and how they work, rather than just going off a tutorial.
http://www.4guysfromrolla.com/webte...ases/faq2.shtml http://www.4guysfromrolla.com/webtech/042599-1.shtml |
|
#6
|
|||
|
|||
|
thank you stumpy for the urls.
I did read articles. The original question came up when I read the article from devarticles.com called "Using MyODBC To Access Your MySQL Database Via ASP". That was recommended by one of the links on mysql.com when I downloaded the ODBC driver. (URL) That's how I found this forum, and that's why I was hoping some people would have read that as well and might provide help. I was following the article's suggestion on setting up my ODBC driver and trying on different things. My original question, was how come I was following the instruction on the article, and still can't get the desire result. Now with all the other URLs, might be they will help me on this and other topics as well. Again, thank you. BTW, anybody out here tried the article in this domain? I would like to know some thought about it... Thank you. |
|
#7
|
|||
|
|||
|
same problem
Hello,
I have same problem and it is my code, thank you for your help <html> <!-- #include virtual="/databas/adovbs.inc" --> <% set Connect = Server.CreateObject("ADODB.Connection") Connnect.Open "DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=kurf;USER=root;P ASSWORD=rishakawweman;OPTION=3;" Set RecSet = Server.CreateObject("ADODB.Recordset") if adoConn.errors.count = 0 then response.write "<h2>Fields In The 'diwan' Table:</h2>" else response.write "ERROR: Couldn't connect to database" end if Addera = "SELECT * FROM diwan" RecSet.Open Addera, Connect, adOpenStatic, adLockOptimistic RecSet.AddNew RecSet("Fornamn") = Request.Form("fornamn") RecSet("Efternamn") = Request.Form("efternamn") RecSet("Nicknamn") = Request.Form("nicknamn") RecSet("Password") = Request.Form("password") RecSet.Update RecSet.Close Connect.Close %> Följande uppgifter har nu lagts till i databasen:<p> Förnamn:<br><b><% =Request.Form("fornamn") %></b><p> Efternamn:<br><b><% =Request.Form("efternamn") %></b><p> Nicknamn:<br><b><% =Request.Form("nicknamn") %></b><p> Password:<br><b><% =Request.Form("password") %></b><p> Lägg till <a href="default.asp">fler poster i adressboken</a>. </html> |
|
#8
|
|||
|
|||
|
cfarne009@yahoo.com
please mail me a working code and please disect it w/ explanations main concern is the connection string dns less im having problem on w/c file should i call as a database set adoConn = Server.CreateObject("ADODB.Connection") set adoRS = Server.CreateObject("ADODB.Recordset") adoConn.Open "driver= {MySQL 3.51 Driver};database=sss; ---> this is the folder of my database server=localhost; uid =root;pwd=;" |
![]() |
| Viewing: Dev Articles Community Forums > Databases > MySQL Development > need some help to connect ASP to mySQL... per "Using MyODBC" article suggestion... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|