Aku dilanda kebodohan dan kemalasan nak cari
nak tanya sket... sapa leh bagi komen.. apa aku perlu buat..ADO.net? or ODBC? or OLEDB?
Imports System.Data.OleDb
Public Class DB_Class
Public tempDB As OleDbConnection
Public Sub New()
tempDB = New OleDbConnection(GetDatabaseName)
End Sub
Public Sub New(ByRef tDB As OleDbConnection, ByVal sDatabasePath As String)
tDB = New OleDbConnection(sDatabasePath)
End Sub
'Get Database Path/DSN
Private Function GetDatabaseName() As String
Return "C:\eReloadAdmin\Database\my_db.mdb"
End Function
'Run query
Public Function RunQuery(ByVal sSqlString As String) As Boolean
Try
'Sangkut la pulok
Catch ex As Exception
End Try
End Function
'Get Recordset
Public Function RunRecordset(ByVal sSqlString As String) As Boolean
Try
'Sangkut la pulok
Catch ex As Exception
End Try
End Function
End Class FYI... aku baru dalam .NET... sblum nih vb6 je.. hheehhehe
dapat mencari sket.. result code terbaru
Imports System.Data.OleDb
Public Class DB_Class
Public tempDB As OleDbConnection
Private oleCommand As OleDbCommand
Public Sub New()
tempDB = New OleDbConnection(GetDatabaseName)
End Sub
Public Sub New(ByRef tDB As OleDbConnection, ByVal sDatabasePath As String)
tDB = New OleDbConnection(sDatabasePath)
End Sub
Public Sub CloseConnection()
If tempDB.State <> ConnectionState.Closed Then
tempDB.Close()
tempDB.Dispose()
End If
End Sub
Public Sub CloseConnection(ByRef tDb As OleDbConnection)
If tDb.State <> ConnectionState.Closed Then
tDb.Close()
tDb.Dispose()
End If
End Sub
'Get Database Path/DSN
Private Function GetDatabaseName() As String
Return "C:\eReloadAdmin\Database\my_db.mdb"
End Function
'Run query
Public Function RunQuery(ByVal sSqlString As String) As Boolean
Try
Dim iResult As Integer
oleCommand = New OleDbCommand(sSqlString, tempDB)
iResult = oleCommand.ExecuteNonQuery()
oleCommand.Dispose()
oleCommand = Nothing
If iResult > 0 Then
Return True
Else
Return False
End If
Catch ex As Exception
Return False
End Try
End Function
Public Function RunQuery(ByVal sSqlString As String, ByRef tDB As OleDbConnection) As Boolean
Try
Dim iResult As Integer
oleCommand = New OleDbCommand(sSqlString, tDB)
iResult = oleCommand.ExecuteNonQuery()
oleCommand.Dispose()
oleCommand = Nothing
If iResult > 0 Then
Return True
Else
Return False
End If
Catch ex As Exception
Return False
End Try
End Function
'Get Recordset
Public Function RunRecordset(ByVal sSqlString As String, ByRef DataReader As OleDbDataReader) As Boolean
Try
oleCommand = New OleDbCommand(sSqlString, tempDB)
DataReader = oleCommand.ExecuteReader()
oleCommand.Dispose()
oleCommand = Nothing
Return True
Catch ex As Exception
Return False
End Try
End Function
Public Function RunRecordset(ByVal sSqlString As String, ByRef DataReader As OleDbDataReader, ByRef tdb As OleDbConnection) As Boolean
Try
oleCommand = New OleDbCommand(sSqlString, tdb)
DataReader = oleCommand.ExecuteReader()
oleCommand.Dispose()
oleCommand = Nothing
Return True
Catch ex As Exception
Return False
End Try
End Function
End Class
kalau dh ada sikap kebodohan & malas mencari... hulur je $$$ pasti ada yg tolong buatkan
;P
Balas #4 BorderManager\ catat
Tak dak feel la kalu gitu... hahahahahah..nih yang dah jalan...
apa pendapat ko.. ok ka?
Imports System.Data.OleDb
Public Class DB_Class
Public tempDB As OleDbConnection
Private oleCommand As OleDbCommand
Public Sub New()
Dim sConnection As String
sConnection = GetDatabaseName()
sConnection = CreateConnectionString(sConnection)
tempDB = New OleDbConnection(sConnection)
tempDB.Open()
End Sub
Public Sub New(ByRef tDB As OleDbConnection, ByVal sDatabasePath As String)
Dim sConnection As String
sConnection = CreateConnectionString(sDatabasePath)
tDB = New OleDbConnection(sConnection)
End Sub
Private Function CreateConnectionString(ByVal sDatabasePath As String) As String
Return "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sDatabasePath & ";User Id=;Password=;"
End Function
Public Sub CloseConnection()
If tempDB.State <> ConnectionState.Closed Then
tempDB.Close()
tempDB.Dispose()
End If
End Sub
Public Sub CloseConnection(ByRef tDb As OleDbConnection)
If tDb.State <> ConnectionState.Closed Then
tDb.Close()
tDb.Dispose()
End If
End Sub
'Get Database Path/DSN
Private Function GetDatabaseName() As String
Return "C:\eReloadAdmin\Database\my_db.mdb"
End Function
'Run query
Public Function RunQuery(ByVal sSqlString As String) As Boolean
Try
Dim iResult As Integer
oleCommand = New OleDbCommand(sSqlString, tempDB)
iResult = oleCommand.ExecuteNonQuery()
oleCommand.Dispose()
oleCommand = Nothing
If iResult > 0 Then
Return True
Else
Return False
End If
Catch ex As Exception
Return False
End Try
End Function
Public Function RunQuery(ByVal sSqlString As String, ByRef tDB As OleDbConnection) As Boolean
Try
Dim iResult As Integer
oleCommand = New OleDbCommand(sSqlString, tDB)
iResult = oleCommand.ExecuteNonQuery()
oleCommand.Dispose()
oleCommand = Nothing
If iResult > 0 Then
Return True
Else
Return False
End If
Catch ex As Exception
Return False
End Try
End Function
'Get Recordset
Public Function RunRecordset(ByVal sSqlString As String, ByRef DataReader As OleDbDataReader) As Boolean
Try
oleCommand = New OleDbCommand(sSqlString, tempDB)
DataReader = oleCommand.ExecuteReader()
oleCommand.Dispose()
oleCommand = Nothing
If DataReader.HasRows Then
Return True
Else
Return False
End If
Catch ex As Exception
Return False
End Try
End Function
Public Function RunRecordset(ByVal sSqlString As String, ByRef DataReader As OleDbDataReader, ByRef tdb As OleDbConnection) As Boolean
Try
oleCommand = New OleDbCommand(sSqlString, tdb)
DataReader = oleCommand.ExecuteReader()
oleCommand.Dispose()
oleCommand = Nothing
Return True
Catch ex As Exception
Return False
End Try
End Function
End Class
sory dah 5 tahun tak buka .NET takleh comment:lol:
Balas #6 BorderManager\ catat
heheheheh...skarang ko develop guna apo? PHP je....programming for fun only
Balas #8 BorderManager\ catat
ooooo....aku skarang dok menggodek .net...
php boleh la sesikit... heheheh saye xske ASP.Net.....................:mad: :mad: :mad:
PHP lg ok kot rasenye.. :)
???
Bukan main drag and drop ke vb?Kata RAD tools :lol: :lol: :lol:Balas #5 i212\ catat
cantik dah nihh.... pas nih function lehh ahh kasi public sharedd ... medium tier nya... br ada businessss logicc baru cenanggg pas nih....
Pages:
[1]