Note that there are some explanatory texts on larger screens.

plurals
  1. POVB.net (aspx) mysql connection
    primarykey
    data
    text
    <p>NET and VB.net code behind. I have a classic ASP page that connects to the mySQL server with the following code:</p> <pre><code> Set oConnection = Server.CreateObject("ADODB.Connection") Set oRecordset = Server.CreateObject("ADODB.Recordset") oConnection.Open "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=example.com; PORT=3306; DATABASE=xxx; USER=xxx; PASSWORD=xxx; OPTION=3;" sqltemp = "select * from userinfo WHERE emailAddress = '" &amp; theUN &amp; "'" oRecordset.Open sqltemp, oConnection,3,3 if oRecordset.EOF then ... </code></pre> <p>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:</p> <pre><code> Dim MyConString As String = "DRIVER={MySQL ODBC 3.51 Driver};" &amp; _ "SERVER=example.com;" &amp; _ "DATABASE=xxx;" &amp; _ "UID=xxx;" &amp; _ "PASSWORD=xxx;" &amp; _ "OPTION=3;" Dim conn As New OdbcConnection(MyConString) conn.Open() Dim MyCommand As New OdbcCommand MyCommand.Connection = MyConnection MyCommand.CommandText = "select * from userinfo WHERE emailAddress = '" &amp; theUN &amp; "'"" MyCommand.ExecuteNonQuery() MyConnection.Close() </code></pre> <p>I have these import statements also:</p> <pre><code> &lt;%@ Import Namespace=System %&gt; &lt;%@ Import Namespace=System.IO %&gt; &lt;%@ Import Namespace=System.Web %&gt; &lt;%@ Import Namespace=System.ServiceProcess %&gt; &lt;%@ Import Namespace=Microsoft.Data.Odbc %&gt; &lt;%@ Import Namespace=MySql.Data.MySqlClient %&gt; &lt;%@ Import Namespace=MySql.Data %&gt; &lt;%@ Import Namespace=System.Data %&gt; </code></pre> <p>The error is as follows:</p> <p>Compiler Error Message: BC30002: Type 'OdbcConnection' is not defined.</p> <p>Source Error:</p> <pre><code> Line 121: "OPTION=3;" Line 122: Line 123: Dim conn As New OdbcConnection(MyConString) '&lt;--error line Line 124: conn.Open() Line 125: </code></pre> <p>So any help would be great! :o)</p> <p><B>EDIT: GOT IT WORKING USING THIS WAY</B></p> <pre><code> Dim MyConString As String = "DRIVER={MySQL ODBC 3.51 Driver};" &amp; _ "SERVER=example.com;" &amp; _ "DATABASE=xxx;" &amp; _ "UID=xxx;" &amp; _ "PASSWORD=xxx;" &amp; _ "OPTION=3;" Dim conn As OdbcConnection = New OdbcConnection(MyConString) conn.Open() Dim MyCommand As New OdbcCommand MyCommand.Connection = conn 'MyCommand.CommandText = "INSERT INTO tablename VALUES("val1","val2","val3")" 'MyCommand.ExecuteNonQuery() conn.Close() </code></pre> <p><B>AND WITH THE mysql.data.DLL IN PLAY</B></p> <pre><code> Dim MyConString As String = "DRIVER={MySQL ODBC 3.51 Driver};" &amp; _ "SERVER=example.com;" &amp; _ "DATABASE=xxx;" &amp; _ "UID=xxx;" &amp; _ "PASSWORD=xxx;" &amp; _ "OPTION=3;" Dim conn As New MySqlConnection(MyConString) conn.Open() Dim MyCommand As New MySqlCommand MyCommand.Connection = conn 'MyCommand.CommandText = "INSERT INTO tablename VALUES("val1","val2","val3")" 'MyCommand.ExecuteNonQuery() conn.Close() </code></pre> <p>David</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload