Rabu, 29 Juli 2020

Menyimpan Setting Koneksi Vb.Net Ms Access

*.accdb" OpenFileDialog1.FileName = "" If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then txtFile.Text = OpenFileDialog1.FileName strConn = "Provider=Microsoft.ACE.OLEDB.12.0;" & "Data Source=" & txtFile.Text & ";" & "Persist Security Info=False;" lblConnectionString.Text = strConn End If End Sub Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click My.Settings.dbPath = txtFile.Text My.Settings.Save() End Sub Private Sub btnCheck_Click(sender As Object, e As EventArgs) Handles btnCheck.Click Dim con As New OleDbConnection(strConn) Dim cmd As New OleDbCommand Dim adapt As New OleDbDataAdapter Dim dt As New DataTable Try con.Open() cmd.Connection = con cmd.CommandText = "SELECT kodekategori, namakategori " & "FROM kategori" adapt.SelectCommand = cmd adapt.Fill(dt) grdData.DataSource = dt con.Close() Catch myerror As OleDbException MessageBox.Show("Error: " & myerror.Message) Finally con.Dispose() End Try End Sub End Class Supaya lebih memahami kegunaan tiap baris aba-aba, temen-temen coder mampu mengikuti tiap langkah dalam artikel ini. Semoga bisa menolong untuk mengetahui dan silahkan copy paste dengan pandai!!! HAPPY CODING ^_^
Sumber http://rani-irsan.blogspot.com


EmoticonEmoticon