Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / database / MySQL

Connecting ASP.NET and MySQL

1.86/5 (4 votes)
30 Jan 2007 1  
Connecting ASP.NET and MySQL

Introduction

This article demonstrates the connection between between ASP.NET and MySQL.

Code

Imports System.Data
Imports System.Data.Odbc


Partial Class connstring
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Dim ConnStr As String = "Server=serverip;Provider=MySQLProv;Driver={MySQL ODBC 3.51 Driver};Database=databasename;uid=username;pwd=password"
Dim conn As New Odbc.OdbcConnection(ConnStr)
Dim olecmd As New Odbc.OdbcCommand("select * from Activity", conn)
Dim reader As Odbc.OdbcDataReader
conn.Open()
reader = olecmd.ExecuteReader
reader.Read()
While reader.Read
Response.Write(reader("Name") & "<br>")
End While


End Sub
End Class

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here