SHARE
TWEET

Koneksi RadioButton Ke MYSQL

stevennathaniel Dec 17th, 2015 98 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Imports System.Data.Odbc
  2.  
  3. Public Class Form5
  4.     'Source code yg berhasil menghubungkan antara radiobutton dengan MYSQL
  5.  
  6.     Dim Gender As String = Nothing
  7.  
  8.     Dim koneksi As OdbcConnection = Nothing
  9.  
  10.     Dim stringKoneksi As String = "DSN=localhost"
  11.  
  12.     Dim stringSQL As String
  13.  
  14.  
  15.  
  16.     Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
  17.  
  18.  
  19.  
  20.         koneksi = New OdbcConnection(stringKoneksi)
  21.  
  22.         stringSQL = "INSERT INTO jeniskelamin(idjeniskelamin,jeniskelamin) VALUES (?,?)"
  23.  
  24.         Try
  25.  
  26.             koneksi.Open()
  27.  
  28.             Dim perintah = New OdbcCommand(stringSQL, koneksi)
  29.  
  30.             perintah.Prepare()
  31.  
  32.             perintah.Parameters.AddWithValue("@idjeniskelamin", TextBox1.Text)
  33.  
  34.             perintah.Parameters.AddWithValue("@jeniskelamin", Gender)
  35.  
  36.             perintah.ExecuteNonQuery()
  37.  
  38.             koneksi.Close()
  39.  
  40.  
  41.  
  42.  
  43.  
  44.         Catch ex As Exception
  45.  
  46.             MessageBox.Show(ex.Message)
  47.  
  48.         End Try
  49.  
  50.  
  51.  
  52.     End Sub
  53.  
  54.     Private Sub RadioButton1_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton1.CheckedChanged
  55.         Gender = "Pria"
  56.     End Sub
  57.  
  58.     Private Sub RadioButton2_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton2.CheckedChanged
  59.         Gender = "Wanita"
  60.     End Sub
  61. End Class
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top