Skip to content

Connecting MySQL with ASP.NET (VB)

February 19, 2007

<%@ Page Language=”VB” AutoEventWireup=”False”
EnableSessionState=”False” EnableViewState=”False” %>
<%@ Import Namespace=”System.Data” %>
<%@ Import Namespace=”System.Data.Odbc” %>

Dim ConnStr As String = “Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=test;uid=root;pwd=passwordhere;option=3”
Dim con As OdbcConnection = New OdbcConnection(ConnStr)
Dim cmd As OdbcCommand = New OdbcCommand(“SELECT * FROM Names”, con)
dgrAllNames.DataSource = cmd.ExecuteReader(CommandBehavior.CloseConnection Or CommandBehavior.SingleResult)

<title>Displaying Records from MySQL ‘Names’ table</title>
body { font: 100% Verdana; }

<p align=”center”>All records in the ‘Names’ table:</p>

<asp:DataGrid ID=”dgrAllNames” HorizontalAlign=”Center”
CellPadding=”3″ Runat=”server” />


No comments yet

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: