Imports System.Data
Imports System.Configuration
Imports MySql.Data.MySqlClient
Imports DevExpress.Web
Partial Class Practice_Default
Inherits System.Web.UI.Page
Dim constr As String = ConfigurationManager.ConnectionStrings("Testmysql").ConnectionString
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
Dim objConn As MySqlConnection
Dim adapter As New MySqlDataAdapter
Dim ds As New DataSet
objConn = New MySqlConnection(constr)
Using cmd As New MySqlCommand()
cmd.CommandText = "select * from `dbo.priceforproduct`"
cmd.Connection = objConn
objConn.Open()
adapter.SelectCommand = cmd
adapter.Fill(ds)
adapter.Dispose()
GridView1.DataSource = ds
GridView1.DataBind()
objConn.Close()
End Using
End Sub
Sub ShowPageCommand(s As Object, e As GridViewPageEventArgs)
GridView1.PageIndex = e.NewPageIndex
GridView1.DataBind()
End Sub
Private Sub ASPxComboBox1_Load(sender As Object, e As EventArgs) Handles ASPxComboBox1.Load
If Not IsPostBack Then
Dim adapter As New MySqlDataAdapter
Dim ds As New DataSet
Using con As New MySqlConnection(constr)
Using cmd As New MySqlCommand("SELECT NO, ZKS_ItemName FROM `dbo.priceforproduct`")
cmd.CommandType = CommandType.Text
cmd.Connection = con
con.Open()
adapter.SelectCommand = cmd
adapter.Fill(ds)
adapter.Dispose()
ASPxComboBox1.DataSource = ds
ASPxComboBox1.TextField = "ZKS_ItemName"
ASPxComboBox1.ValueField = "NO"
ASPxComboBox1.Text = "Please Select Product"
ASPxComboBox1.DataBind()
con.Close()
End Using
End Using
End If
End Sub
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim objConn As MySqlConnection
Dim adapter As New MySqlDataAdapter
Dim ds As New DataSet
objConn = New MySqlConnection(constr)
Using cmd As New MySqlCommand()
cmd.CommandText = "select *"
cmd.CommandText += " from `dbo.priceforproduct`"
cmd.CommandText += " where NO = @NO"
cmd.Parameters.AddWithValue("@NO", ASPxComboBox1.SelectedItem.Value)
cmd.Connection = objConn
objConn.Open()
adapter.SelectCommand = cmd
adapter.Fill(ds)
adapter.Dispose()
GridView1.DataSource = ds
GridView1.DataBind()
objConn.Close()
End Using
End Sub
Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Response.Redirect("formadd.aspx")
End Sub
Protected Sub DeleteCustomer(ByVal sender As Object, ByVal e As EventArgs)
Dim lnkRemove As LinkButton = DirectCast(sender, LinkButton)
Dim objConn As MySqlConnection
Dim adapter As New MySqlDataAdapter
Dim ds As New DataSet
objConn = New MySqlConnection(constr)
Using cmd As New MySqlCommand()
cmd.CommandType = CommandType.Text
cmd.CommandText = "Delete from `dbo.priceforproduct` where NO = @NO;" _
& "select NO, ZKS_Type, ZKS_CateCode, ColorCode, ZKS_ItemCode, ZKS_ItemName," _
& "ZKS_SheetLong, ZKS_Unit, ZKS_Prices_exv from `dbo.priceforproduct`"
cmd.Parameters.Add("@NO", MySqlDbType.VarChar).Value _
= lnkRemove.CommandArgument
cmd.Connection = objConn
objConn.Open()
adapter.SelectCommand = cmd
adapter.Fill(ds)
adapter.Dispose()
GridView1.DataSource = ds
GridView1.DataBind()
objConn.Close()
End Using
End Sub
End Class
Tag : .NET, MySQL, VBScript, Web (ASP.NET), XAMPP, Windows