Imports Telerik.Web.UI
Imports MySql.Data.MySqlClient
Imports System.Data
Partial Class EmptyVBPage
    Inherits System.Web.UI.Page

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


    End Sub

	Protected Sub RadGrid1_NeedDataSource(ByVal source As Object, ByVal e As GridNeedDataSourceEventArgs)
		RadGrid1.DataSource = GetDataTable("SELECT CustomerID, CompanyName, ContactName, ContactTitle, Address, PostalCode FROM Customers")
	End Sub

	Public Function GetDataTable(ByVal query As String) As DataTable
		Dim ConnString As String = ConfigurationManager.ConnectionStrings("MySqlNorthwindConnectionString").ConnectionString
		Dim conn As MySqlConnection = New MySqlConnection(ConnString)
		Dim adapter As MySqlDataAdapter = New MySqlDataAdapter
		adapter.SelectCommand = New MySqlCommand(query, conn)
		Dim table1 As New DataTable
		conn.Open()
		Try
			adapter.Fill(table1)
		Finally
			conn.Close()
		End Try
		Return table1
	End Function
End Class
