Why can not save to the database?
my script
Imports MySql.Data.MySqlClient
Imports System.Data.Odbc
Public Class Arsip
Const DSN = "DSN=arsip"
Dim conn As OdbcConnection
Dim cmd As OdbcCommand
Dim da As OdbcDataAdapter
Dim dr As OdbcDataReader
Dim ds As DataSet
Dim table As DataTable
Sub koneksi()
conn = New OdbcConnection(DSN)
If conn.State = ConnectionState.Closed Then
conn.Open()
End If
End Sub
Sub tampilkan_data()
koneksi()
da = New OdbcDataAdapter("select * from arsip", conn)
ds = New DataSet
ds.Clear()
da.Fill(ds, 0)
table = ds.Tables(0)
DGV.DataSource = table
conn.Close()
End Sub
Private Sub Arsip_Load(sender As Object, e As EventArgs) Handles MyBase.Load
tampilkan_data()
End Sub
Private Sub btnsimpan_Click(sender As Object, e As EventArgs) Handles btnsimpan.Click
Try
koneksi()
cmd = New OdbcCommand("insert into arsip values (?, ?, ?, ?)", conn)
With cmd
.Parameters.AddWithValue("?", TextNO.Text)
.Parameters.AddWithValue("?", TextJenis.Text)
.ExecuteNonQuery()
End With
conn.Close()
tampilkan_data()
TextNO.Text = ""
TextJenis.Text = ""
TextNO.Focus()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub TextJenis_TextChanged(sender As Object, e As EventArgs) Handles TextJenis.TextChanged
End Sub
Private Sub DateTimePicker1_ValueChanged(sender As Object, e As EventArgs) Handles DateTimePicker1.ValueChanged
End Sub
End Class