CariDotMy

 Forgot password?
 Register

ADVERTISEMENT

View: 3253|Reply: 11

Aku dilanda kebodohan dan kemalasan nak cari

[Copy link]
Post time 31-1-2009 11:12 AM | Show all posts |Read mode
nak tanya sket... sapa leh bagi komen.. apa aku perlu buat..
ADO.net? or ODBC? or OLEDB?

  1. Imports System.Data.OleDb


  2. Public Class DB_Class
  3.     Public tempDB As OleDbConnection

  4.     Public Sub New()
  5.         tempDB = New OleDbConnection(GetDatabaseName)
  6.     End Sub

  7.     Public Sub New(ByRef tDB As OleDbConnection, ByVal sDatabasePath As String)
  8.         tDB = New OleDbConnection(sDatabasePath)
  9.     End Sub

  10.     'Get Database Path/DSN
  11.     Private Function GetDatabaseName() As String
  12.         Return "C:\eReloadAdmin\Database\my_db.mdb"
  13.     End Function

  14.     'Run query
  15.     Public Function RunQuery(ByVal sSqlString As String) As Boolean
  16.         Try
  17.             'Sangkut la pulok
  18.         Catch ex As Exception

  19.         End Try
  20.     End Function

  21.     'Get Recordset
  22.     Public Function RunRecordset(ByVal sSqlString As String) As Boolean
  23.         Try
  24.             'Sangkut la pulok
  25.         Catch ex As Exception

  26.         End Try
  27.     End Function


  28. End Class
Copy the Code
Reply

Use magic Report


ADVERTISEMENT


 Author| Post time 31-1-2009 11:27 AM | Show all posts
FYI... aku baru dalam .NET... sblum nih vb6 je.. hheehhehe
Reply

Use magic Report

 Author| Post time 31-1-2009 11:49 AM | Show all posts

dapat mencari sket.. result code terbaru


  1. Imports System.Data.OleDb


  2. Public Class DB_Class
  3.     Public tempDB As OleDbConnection
  4.     Private oleCommand As OleDbCommand

  5.     Public Sub New()
  6.         tempDB = New OleDbConnection(GetDatabaseName)
  7.     End Sub

  8.     Public Sub New(ByRef tDB As OleDbConnection, ByVal sDatabasePath As String)
  9.         tDB = New OleDbConnection(sDatabasePath)
  10.     End Sub

  11.     Public Sub CloseConnection()
  12.         If tempDB.State <> ConnectionState.Closed Then
  13.             tempDB.Close()
  14.             tempDB.Dispose()
  15.         End If
  16.         
  17.     End Sub

  18.     Public Sub CloseConnection(ByRef tDb As OleDbConnection)
  19.         If tDb.State <> ConnectionState.Closed Then
  20.             tDb.Close()
  21.             tDb.Dispose()
  22.         End If
  23.     End Sub

  24.     'Get Database Path/DSN
  25.     Private Function GetDatabaseName() As String
  26.         Return "C:\eReloadAdmin\Database\my_db.mdb"
  27.     End Function

  28.     'Run query
  29.     Public Function RunQuery(ByVal sSqlString As String) As Boolean
  30.         Try
  31.             Dim iResult As Integer
  32.             oleCommand = New OleDbCommand(sSqlString, tempDB)
  33.             iResult = oleCommand.ExecuteNonQuery()
  34.             oleCommand.Dispose()
  35.             oleCommand = Nothing
  36.             If iResult > 0 Then
  37.                 Return True
  38.             Else
  39.                 Return False
  40.             End If
  41.         Catch ex As Exception
  42.             Return False
  43.         End Try
  44.     End Function

  45.     Public Function RunQuery(ByVal sSqlString As String, ByRef tDB As OleDbConnection) As Boolean
  46.         Try
  47.             Dim iResult As Integer
  48.             oleCommand = New OleDbCommand(sSqlString, tDB)
  49.             iResult = oleCommand.ExecuteNonQuery()
  50.             oleCommand.Dispose()
  51.             oleCommand = Nothing
  52.             If iResult > 0 Then
  53.                 Return True
  54.             Else
  55.                 Return False
  56.             End If
  57.         Catch ex As Exception
  58.             Return False
  59.         End Try
  60.     End Function

  61.     'Get Recordset
  62.     Public Function RunRecordset(ByVal sSqlString As String, ByRef DataReader As OleDbDataReader) As Boolean
  63.         Try
  64.             oleCommand = New OleDbCommand(sSqlString, tempDB)
  65.             DataReader = oleCommand.ExecuteReader()
  66.             oleCommand.Dispose()
  67.             oleCommand = Nothing
  68.             Return True
  69.         Catch ex As Exception
  70.             Return False
  71.         End Try
  72.     End Function

  73.     Public Function RunRecordset(ByVal sSqlString As String, ByRef DataReader As OleDbDataReader, ByRef tdb As OleDbConnection) As Boolean
  74.         Try
  75.             oleCommand = New OleDbCommand(sSqlString, tdb)
  76.             DataReader = oleCommand.ExecuteReader()
  77.             oleCommand.Dispose()
  78.             oleCommand = Nothing
  79.             Return True
  80.         Catch ex As Exception
  81.             Return False
  82.         End Try
  83.     End Function
  84. End Class

Copy the Code
Reply

Use magic Report

Post time 31-1-2009 10:00 PM | Show all posts
kalau dh ada sikap kebodohan & malas mencari... hulur je $$$ pasti ada yg tolong buatkan

Reply

Use magic Report

 Author| Post time 31-1-2009 10:52 PM | Show all posts

Balas #4 BorderManager\ catat

Tak dak feel la kalu gitu... hahahahahah..

nih yang dah jalan...

apa pendapat ko.. ok ka?


  1. Imports System.Data.OleDb


  2. Public Class DB_Class
  3.     Public tempDB As OleDbConnection
  4.     Private oleCommand As OleDbCommand

  5.     Public Sub New()
  6.         Dim sConnection As String
  7.         sConnection = GetDatabaseName()
  8.         sConnection = CreateConnectionString(sConnection)
  9.         tempDB = New OleDbConnection(sConnection)
  10.         tempDB.Open()

  11.     End Sub

  12.     Public Sub New(ByRef tDB As OleDbConnection, ByVal sDatabasePath As String)
  13.         Dim sConnection As String
  14.         sConnection = CreateConnectionString(sDatabasePath)
  15.         tDB = New OleDbConnection(sConnection)
  16.     End Sub

  17.     Private Function CreateConnectionString(ByVal sDatabasePath As String) As String
  18.         Return "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sDatabasePath & ";User Id=;Password=;"
  19.     End Function

  20.     Public Sub CloseConnection()
  21.         If tempDB.State <> ConnectionState.Closed Then
  22.             tempDB.Close()
  23.             tempDB.Dispose()
  24.         End If
  25.         
  26.     End Sub

  27.     Public Sub CloseConnection(ByRef tDb As OleDbConnection)
  28.         If tDb.State <> ConnectionState.Closed Then
  29.             tDb.Close()
  30.             tDb.Dispose()
  31.         End If
  32.     End Sub

  33.     'Get Database Path/DSN
  34.     Private Function GetDatabaseName() As String
  35.         Return "C:\eReloadAdmin\Database\my_db.mdb"
  36.     End Function

  37.     'Run query
  38.     Public Function RunQuery(ByVal sSqlString As String) As Boolean
  39.         Try
  40.             Dim iResult As Integer
  41.             oleCommand = New OleDbCommand(sSqlString, tempDB)
  42.             iResult = oleCommand.ExecuteNonQuery()
  43.             oleCommand.Dispose()
  44.             oleCommand = Nothing
  45.             If iResult > 0 Then
  46.                 Return True
  47.             Else
  48.                 Return False
  49.             End If
  50.         Catch ex As Exception
  51.             Return False
  52.         End Try
  53.     End Function

  54.     Public Function RunQuery(ByVal sSqlString As String, ByRef tDB As OleDbConnection) As Boolean
  55.         Try
  56.             Dim iResult As Integer
  57.             oleCommand = New OleDbCommand(sSqlString, tDB)
  58.             iResult = oleCommand.ExecuteNonQuery()
  59.             oleCommand.Dispose()
  60.             oleCommand = Nothing
  61.             If iResult > 0 Then
  62.                 Return True
  63.             Else
  64.                 Return False
  65.             End If
  66.         Catch ex As Exception
  67.             Return False
  68.         End Try
  69.     End Function

  70.     'Get Recordset
  71.     Public Function RunRecordset(ByVal sSqlString As String, ByRef DataReader As OleDbDataReader) As Boolean
  72.         Try
  73.             oleCommand = New OleDbCommand(sSqlString, tempDB)
  74.             DataReader = oleCommand.ExecuteReader()
  75.             oleCommand.Dispose()
  76.             oleCommand = Nothing
  77.             If DataReader.HasRows Then
  78.                 Return True
  79.             Else
  80.                 Return False
  81.             End If
  82.         Catch ex As Exception
  83.             Return False
  84.         End Try
  85.     End Function

  86.     Public Function RunRecordset(ByVal sSqlString As String, ByRef DataReader As OleDbDataReader, ByRef tdb As OleDbConnection) As Boolean
  87.         Try
  88.             oleCommand = New OleDbCommand(sSqlString, tdb)
  89.             DataReader = oleCommand.ExecuteReader()
  90.             oleCommand.Dispose()
  91.             oleCommand = Nothing
  92.             Return True
  93.         Catch ex As Exception
  94.             Return False
  95.         End Try
  96.     End Function
  97. End Class

Copy the Code
Reply

Use magic Report

Post time 31-1-2009 11:05 PM | Show all posts
sory dah 5 tahun tak buka .NET takleh comment
Reply

Use magic Report

Follow Us
 Author| Post time 31-1-2009 11:32 PM | Show all posts

Balas #6 BorderManager\ catat

heheheheh...
skarang ko develop guna apo?
Reply

Use magic Report

Post time 1-2-2009 12:46 AM | Show all posts
PHP je....programming for fun only
Reply

Use magic Report


ADVERTISEMENT


 Author| Post time 1-2-2009 11:19 AM | Show all posts

Balas #8 BorderManager\ catat

ooooo....
aku skarang dok menggodek .net...
php boleh la sesikit... heheheh
Reply

Use magic Report

Post time 1-2-2009 06:29 PM | Show all posts
saye xske ASP.Net.....................
PHP lg ok kot rasenye..
Reply

Use magic Report

Post time 15-2-2009 01:42 PM | Show all posts

???

Bukan main drag and drop ke vb?Kata RAD tools
Reply

Use magic Report

Post time 17-2-2009 04:10 PM | Show all posts

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....
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

 

ADVERTISEMENT


Forum Hot Topic

 

ADVERTISEMENT


 


ADVERTISEMENT
Follow Us

ADVERTISEMENT


Mobile|Archiver|Mobile*default|About Us|CariDotMy

24-1-2025 09:12 PM GMT+8 , Processed in 2.532965 second(s), 25 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

Quick Reply To Top Return to the list