[SIZE=2][COLOR=#0000ff]Public[/COLOR][/SIZE][SIZE=2] conn [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] OleDbConnection([/SIZE][SIZE=2][COLOR=#800000]"Provider=Microsoft.Jet.OLEDB.4.0;"[/COLOR][/SIZE][SIZE=2] _[/SIZE]
[SIZE=2]& [/SIZE][SIZE=2][COLOR=#800000]"Data Source ="[/COLOR][/SIZE][SIZE=2] & Application.StartupPath & [/SIZE][SIZE=2][COLOR=#800000]"\Store.mdb "[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff]Public[/COLOR][/SIZE][SIZE=2] cmd [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] OleDbCommand[/SIZE]
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] cmdAdd_Click([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] Button1.Click[/SIZE]
[SIZE=2]ListBox1.Items.Clear()[/SIZE]
[SIZE=2]cmd.Connection = conn[/SIZE]
[SIZE=2][COLOR=#008000]'Add text to DB-TBinMaterial[/COLOR][/SIZE]
[SIZE=2]cmd.CommandText = [/SIZE][SIZE=2][COLOR=#800000]"INSERT INTO TBinMaterial(inMaterial) "[/COLOR][/SIZE][SIZE=2] & [/SIZE][SIZE=2][COLOR=#800000]"values ('"[/COLOR][/SIZE][SIZE=2] & txtAddM.Text & [/SIZE][SIZE=2][COLOR=#800000]"') "[/COLOR][/SIZE]
[SIZE=2]cmd.CommandType = CommandType.Text[/SIZE]
[SIZE=2]conn.Open()[/SIZE]
[SIZE=2]cmd.ExecuteNonQuery()[/SIZE]
[SIZE=2][COLOR=#008000]'Load the datat from DB-inMaterial to ListBox1[/COLOR][/SIZE]
[SIZE=2]cmd.CommandText = [/SIZE][SIZE=2][COLOR=#800000]"Select * from TBinMaterial "[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] dr [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] OleDbDataReader = cmd.ExecuteReader[/SIZE]
[SIZE=2][COLOR=#0000ff]Do[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]While[/COLOR][/SIZE][SIZE=2] dr.Read()[/SIZE]
[SIZE=2]ListBox1.Items.Add(dr.Item([/SIZE][SIZE=2][COLOR=#800000]"inMaterial"[/COLOR][/SIZE][SIZE=2]))[/SIZE]
[SIZE=2][COLOR=#0000ff]Loop[/COLOR][/SIZE]
[SIZE=2]conn.Close()[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] cmdDelete_Click([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] Button2.Click[/SIZE]
[SIZE=2][COLOR=#008000]'Delete one data from DB, and load the remainder data[/COLOR][/SIZE]
[SIZE=2]cmd.Connection = conn[/SIZE]
[SIZE=2][COLOR=#008000]'Delete the data according the text of listbox1[/COLOR][/SIZE]
[SIZE=2]cmd.CommandText = [/SIZE][SIZE=2][COLOR=#800000]"DELETE From TBinMaterial where inMaterial = @inMaterial "[/COLOR][/SIZE]
[SIZE=2]cmd.Parameters.AddWithValue([/SIZE][SIZE=2][COLOR=#800000]"@inMaterial"[/COLOR][/SIZE][SIZE=2], ListBox1.Text)[/SIZE]
[SIZE=2]conn.Open()[/SIZE]
[SIZE=2]cmd.ExecuteNonQuery()[/SIZE]
[SIZE=2]ListBox1.Items.Clear()[/SIZE]
[SIZE=2][COLOR=#008000]'Load the data from DB to ListBox1[/COLOR][/SIZE]
[SIZE=2]cmd.CommandText = [/SIZE][SIZE=2][COLOR=#800000]"Select * from TBinMaterial "[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] dr [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] OleDbDataReader = cmd.ExecuteReader[/SIZE]
[SIZE=2][COLOR=#0000ff]Do[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]While[/COLOR][/SIZE][SIZE=2] dr.Read()[/SIZE]
[SIZE=2]ListBox1.Items.Add(dr.Item([/SIZE][SIZE=2][COLOR=#800000]"inMaterial"[/COLOR][/SIZE][SIZE=2]))[/SIZE]
[SIZE=2][COLOR=#0000ff]Loop[/COLOR][/SIZE]
[SIZE=2]conn.Close()[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]