VB.net (aspx) mysql connection

Posted by StealthRT on Stack Overflow See other posts from Stack Overflow or by StealthRT
Published on 2010-04-09T20:18:14Z Indexed on 2010/04/09 20:23 UTC
Read the original article Hit count: 536

Filed under:
|
|
|

Hey all i am new to ASP.NET and VB.net code behind. I have a classic ASP page that connects to the mySQL server with the following code:

 Set oConnection = Server.CreateObject("ADODB.Connection")
 Set oRecordset = Server.CreateObject("ADODB.Recordset")

 oConnection.Open "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=xxx.com; PORT=3306;      DATABASE=xxx; USER=xxx; PASSWORD=xxx; OPTION=3;"
 sqltemp = "select * from userinfo WHERE emailAddress = '" & theUN & "'"
 oRecordset.Open sqltemp, oConnection,3,3

 if oRecordset.EOF then
 ...

However, i am unable to find anything to connect to mySQL in ASP.NET (VB.NET). I have only found this peice of code that does not seem to work once it gets to the "Dim conn As New OdbcConnection(MyConString)" code:

 Dim MyConString As String = "DRIVER={MySQL ODBC 3.51 Driver};" & _
    "SERVER=xxx.com;" & _
    "DATABASE=xxx;" & _
    "UID=xxx;" & _
    "PASSWORD=xxx;" & _
    "OPTION=3;"

    Dim conn As New OdbcConnection(MyConString)
    MyConnection.Open()

    Dim MyCommand As New OdbcCommand
    MyCommand.Connection = MyConnection
    MyCommand.CommandText = "select * from userinfo WHERE emailAddress = '" & theUN & "'""
    MyCommand.ExecuteNonQuery()
    MyConnection.Close()

I have these import statements also:

 <%@ Import Namespace=System %>
 <%@ Import Namespace=System.IO %>
 <%@ Import Namespace=System.Web %>
 <%@ Import Namespace=System.ServiceProcess %>
 <%@ Import Namespace=Microsoft.Data.Odbc %>
 <%@ Import Namespace=MySql.Data.MySqlClient %>
 <%@ Import Namespace=MySql.Data %>
 <%@ Import Namespace=System.Data %>

So any help would be great! :o)

David

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about mysql