Buat sebuah class.
Listing:
Imports System.Configuration
Imports System.Data.Sql
Imports System.Data.OleDb
Imports System.IO
Public Class Class1
Dim conn As OleDbConnection
Public Sub fcConnect()
Dim connString As String
connString = ConfigurationManager.ConnectionStrings("cnnString").ConnectionString()
conn = New OleDbConnection(connString)
End Sub
Public Function sQuery(ByVal mysql As String) As DataSet
Dim da As OleDbDataAdapter
Dim ds As DataSet = New DataSet()
da = New OleDbDataAdapter(mysql, conn)
da.Fill(ds)
Return ds
End Function
Public Function update(ByVal mysql As String) As Boolean
Dim result As Boolean
Dim cmd As OleDbCommand
result = True
conn.Open()
cmd = New OleDbCommand(mysql, conn)
Try
cmd.ExecuteNonQuery()
Catch ex As Exception
result = False
End Try
conn.Close()
Return result
End Function
End Class
No comments:
Post a Comment