Connecting to mySQL database using ASP

Discussion in 'C#' started by cigi, Jan 15, 2009.

  1. #1
    Hey guys,

    Normaly I use or code in PHP and use mySQL. So I'm very new to ASP.

    But I need to access a mySQL database using ASP. I've searched the web and tested many different methods with no success.

    The code below is what I'm trying to use:

    <% 
    strConnection = "Driver={MySQL ODBC 3.51 Driver};Server=mysql-03.xcalibre.co.uk;Port=3306;Option=131072;Stmt=;Database=mission;Uid=XXXX;Pwd=XXXX"
    
    Set adoConn = Server.CreateObject("ADODB.Connection") 
    
    adoConn.Open strConnection 
    
    strQuery = "SELECT * FROM venues;"
    Set RecordSet = adoConn.Execute(strQuery) 
    %>
    Code (markup):
    When running the code I get 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

    /information/connection.asp, line 17


    I've tried just using Driver={MySQL} but I still get the same error.

    Can any one help with this please?

    Thanks for your help.
     
    cigi, Jan 15, 2009 IP
  2. Kyriakos

    Kyriakos Active Member

    Messages:
    155
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #2
    do you have installed the mySQL ODBC software?
     
    Kyriakos, Apr 23, 2009 IP
  3. web-bod

    web-bod Guest

    Messages:
    17
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    "DRIVER={MySQL ODBC 3.51 Driver};SERVER=999.0.0.1;DATABASE=zzzz;USER=yyyy;PASSWORD=xxxx;OPTION=3;"

    works for me.

    Or you could try mysqlhelper which makes life a bit easier
     
    web-bod, Apr 24, 2009 IP
  4. emlak

    emlak Peon

    Messages:
    50
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I have a website at my sign emlak (generally all of my sites created with asp mysql)

    set strconn = server.createobject("adodb.connection")
    strconn.open = "driver={mysql odbc 3.51 driver}; server=your ip or localhost; UID=username; pwd=password; db=databasename"

    your ip or localhost : if your hosting provider is support remote ip connection then server = your ip
    if your hosting provider is not support remote ip connection then server = localhost

    
    set strconn = server.createobject("adodb.connection")
    strconn.open = "driver={mysql odbc 3.51 driver}; server=[B]your ip or localhost[/B]; UID=[B]username[/B]; pwd=[B]password[/B]; db=[B]databasename[/B]"
    
    sql="select * from your_table_name"
    set  sql_query =strconn.execute(sql)
    
    if not sql_query.eof then
    while  not  sql_query .eof
    
    resonse.write sql_query("filed_name")
    
     sql_query .movenext
    wend
    
    
    
    end if
    
    
    
    Code (markup):
    Asp and mysql is very fast . I recommend for you , for your all projects.

    on your local computer:
    mysql and its driver must be installed.
     
    emlak, Apr 25, 2009 IP
  5. mavili

    mavili Active Member

    Messages:
    11
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    88
    #5
    yes, you must firstly install mysql odbc driver. you can find it mysql web site (or a simple search in google as mysql odbc driver download)
     
    mavili, May 6, 2009 IP
  6. tihomir_wwf

    tihomir_wwf Active Member

    Messages:
    363
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    73
    #6
    Hi, I use mysql in one of my asp.net site and it's really easy, in the article below, I share my whole experience about (configuring, examples, using MySql in SqlDataSource/GridView):

    using mysql in asp.net

    I hope it'll be useful :)
     
    tihomir_wwf, May 7, 2009 IP
  7. MayurGondaliya

    MayurGondaliya Well-Known Member

    Messages:
    1,233
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    170
    #7
    I never did the mysql connection from asp. However, in asp.net, I have used it several times. It is very easy and straight forward in .NET. You can use the managed component (ADO.NET driver for .NET) named MYSQL.DATA.DLL which is developed by mysql itself. You can find the sample code for retrieving data and exexuting operations on mysql database using any .net language here.

    http://ask4asp.net/post/using-mysql...anding-database-operations-mysql-asp_net.aspx
     
    MayurGondaliya, May 7, 2009 IP