About the author

Imran Imran
Like Development in DotNet.

E-mail me Send mail

Recent Articles

 
1: Roles And Membership
Category: ASP.Net
Added: 6/2/2008

 
2: ListView and DataPager in ASP.NET 3.5
Category: ASP.Net
Added: 5/15/2008

 
3: Asp.Net Cookies
Category: ASP.Net
Added: 5/8/2008

 
4: DatagridDatalistRepeater
Category: ASP.Net
Added: 5/8/2008

 
5: mySql With Asp.Net
Category: Databases
Added: 4/16/2008

 
6: MDF without LDF
Category: Databases
Added: 4/16/2008

 
7: Disable Right Click
Category: Java Script
Added: 4/16/2008

 
8: String Functions
Category: ASP.Net
Added: 3/20/2008

 
9: Water Mark
Category: HTML & DHTML
Added: 3/20/2008

 
10: Ajax With Javascript
Category: AJAX
Added: 3/10/2008

mySql With Asp.Net

by Imran 16/April/2008

Here is an example for mySQL with Asp.Net

First Step to connect with mySql you should download mysql Driver from following links

http://dev.mysql.com/downloads/connector/odbc/3.51.html

http://dev.mysql.com/get/Downloads/Connector-ODBC/3.51/
mysql-connector-odbc-3.51.24-win32.msi/from/pick?done=ef2959aa46636b


Then right code same like

Imports System.Data
Imports System.Data.Odbc


Partial Class test2
    Inherits System.Web.UI.Page
    Dim myconstr2 = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=server; DATABASE=yourdb;USER=dbuser;PASSWORD=dbpassword; OPTION=3;"

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim sql As String = "select * from table"
        Dim ds As New DataSet
        ds = FillDS(sql)
        Response.Write(ds.Tables(0).Rows.Count)
    End Sub


    Private Function FillDS(ByVal sql As String) As DataSet
        Dim con As New OdbcConnection(myconstr2)
        Dim da As New OdbcDataAdapter(sql, con)
        Dim ds As New DataSet
        da.Fill(ds)
        con.Close()
        Return ds
    End Function
End Class



Powered by DotNetClassic.com