By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,987 Members | 1,607 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,987 IT Pros & Developers. It's quick & easy.

database connection problem

P: 5
I am trying to connect to a database, but the Con.ConnectionString is empty....Does anyone know where to assign a value of Con.ConnectionString?
Here's my code below....
'================================================= =====
Public Class ClassTool
Dim DB As New ClassHelper

Public Sub New(ByVal Factory As Integer, ByVal sConn As String)
DB.ConnectionString = sConn
DB.Factory = Factory
End Sub

End Class
'''''''''''''''''''''''''''''''''''''''''''
Public Class ClassHelper
Public Shared Con As DbConnection
Private Shared _connectionstring As String
Private Shared oProviderFactory As DbProviderFactory
Private Shared _factory As Providers

Public Enum Providers As Integer
Odbc = 1
OleDb = 2
SqlClient = 3
OracleClient = 4
MySql = 5
End Enum

Public Property Factory() As Providers
Get
Return _factory
End Get
Set(ByVal value As Providers)
_factory = value
oProviderFactory = DbProviderFactories.GetFactory(GetFactoryByProvide r(_factory))
'oProviderFatory gets the value "System.Data.OleDb"
Con = oProviderFactory.CreateConnection
End Set
End Property

Public Property ConnectionString() As String
Get
Return _connectionstring
End Get
Set(ByVal value As String)
_connectionstring = value
End Set
End Property

End Class
Apr 26 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.