cobacoba2

download cobacoba2

If you can't read please download the document

description

dfgfgcg

Transcript of cobacoba2

Imports mysql.Data.mysqlclient Public Class Form1 Dim strkon As String = "server=localhost;uid=root;database=conter" Dim kon As New MySqlconnection(strkon) Dim perintah As New MySqlCommand Dim mda As New MySqlDataAdapter Dim ds As New DataSet Dim cek As MySqlDataReader Sub tampil() kon.open() perintah.Connection = kon perintah.CommandType = CommandType.Text perintah.CommandText = "select * from hp" mda.SelectCommand = perintah ds.Tables.Clear() mda.Fill(ds, "T") DataGridView1.DataSource = ds.Tables("T") kon.Close() End Sub Sub bersih() TextBox1.Text TextBox2.Text TextBox3.Text TextBox4.Text TextBox5.Text End Sub

= = = = =

"" "" "" "" ""

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.Even tArgs) Handles MyBase.Load tampil() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.E ventArgs) Handles Button1.Click kon.Open() perintah.CommandType = CommandType.Text perintah.CommandText = "INSERT INTO hp VALUES ('" & TextBox1.Text & "',' " & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & Text Box5.Text & "')" perintah.ExecuteNonQuery() MsgBox("Data tersimpan") kon.Close() tampil() bersih() End Sub Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windo ws.Forms.KeyEventArgs) Handles TextBox1.KeyDown Select Case e.KeyCode Case Keys.Enter kon.Open() perintah.CommandType = CommandType.Text perintah.CommandText = "select * from hp where hpid='" & TextBox 1.Text & "'" cek = perintah.ExecuteReader

cek.Read() If cek.HasRows Then TextBox2.Text = TextBox3.Text = TextBox4.Text = TextBox5.Text = End If kon.Close() End Select End Sub

cek.Item("hptipe") cek.Item("hpmerkid") cek.Item("hpwarna") cek.Item("hpstock")

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As S ystem.EventArgs) Handles TextBox1.TextChanged End Sub End Class