Cari Data
sub jurusan()
call koneksi
tampil2.connection = database
tampil2.CommandType = Commandtype.Text
tampil2.CommandText = "select * from jurusan where kdjur='" &Trim(TextBox1.Text)& "'
tampilkan = tampil2.Executereader
if tampilkan.Hasrows = True than
while tampilkan.read()
if ISDBNull (Tampilkan("kdjur")) Then
TextBox2.text="_"
else
TextBox2.Text = Tampilkan("nmjur")
End if
End While
End if
CEK RECORD
Sub cekrecord()
call koneksi()
tampil.connection = database
tampil.commandType=commandtype.Text
tampil.commandText = "Select * from jurusan where kd='" & trim(Textbox1.text)& "'
tampilkan = tampil.executeReader
if tampilkan.Hasrows = true then
hasilcek = true
else
hasilcek = false
end if
end sub
INSERT DATA
if TextBox1.Text = "" Then exit sub
if TextBox2.Text = "" Then Exit Sub
call koneksi()
Try
if hasilcek = "false" then
call koneksi()
tampil.connection = database
tampil.commandType = CommandText.Text
tampil.commandType = " insert into jurusan (kdjur,nmjur)values('" & TextBox1.text & "','" & TextBox.text & "')"
tampil.ExecuteNonQuery()
call kosong()
else
msgBox("data sudah ada", msgboxStyle.Critical,"input data")
textbox1.focus()
end if
Catch ex As exception
msgBox(ex.ToString())
end if
end sub
UBAH DATA/ UPDATE/b>
Try
call koneksi()
tampil.connection= database
tampil.commandType = commandType.Text
tampil.commandText = " update jurusan set nmjur='"& Trim(TextBox2.Text) & "' where
kdjur = '" & Trim(TextBox1.Text) & "'"
tampil.ExecuteNonQuery()
call kosong()
TextBox1.Focus()
catch ex As Exception
msgBox(ex.ToString())
end try
end sub
Rabu, 08 Juni 2011
Langganan:
Postingan (Atom)