ConnectionString



Hi I have the following for My Database connection in my project:

Con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=J:\Database\MasterDB.mdb"
UP.Connection = Con
UP.CommandType = CommandType.Text
UP.CommandText = "Select * From Passwords Where Users_Name=? and
Users_Password=?"

I`ve now want to use a connection class of (Allowing me use choose a
Database to Use):

Private Shared mConnectionsstring As String =
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
Private Shared mLocation As String
Private Shared connArray As ArrayList
Public Shared Sub setString(ByVal ind As Integer)
Dim connArray As New ArrayList
connArray.Add("D:\Database\MasterDB.mdb")
connArray.Add("D:\Database\LocalDB.mdb")
'Use For Debugging DB Connection Errors
'MessageBox.Show(ind.ToString())
mLocation = connArray(ind).ToString
End Sub
Public Shared ReadOnly Property [String]() As String
Get
Return "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & mLocation & ";"
End Get
End Property

I know I need to change my "Con.ConnectionString =
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=J:\Database\MasterDB.mdb" I
thought it would be changed to:

Con.ConnectionString = Me.cboSelectDB.SelectedIndex but then it tells me
"Option Strict On disallows implicit conversions from 'Integer' to 'String'"
if I take Options Strict On off it errors and says: "Format of the
initialization string does not conform to specification starting at index
0."

Could somebody kindly point me in the right Direction for a fix?

Many Thanks
NSC




.



Relevant Pages

  • Re: ConnectionString
    ... > Hi I have the following for My Database connection in my project: ... > Private Shared mLocation As String ... > Public Shared ReadOnly Property As String ...
    (microsoft.public.dotnet.framework.adonet)
  • About SQLDataReader
    ... I'm pretty sure that if you haven't an open a database connection when you ... string customerId = Console.ReadLine; ... "Select OrderID, OrderDate, " + ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: how to make this variable available to other subs
    ... you can declare the connection globally (I assume you mean somewhere ... > global.aspx) like you would a string or integer and use the open and close ... > | database connection object variable. ... > | every sub. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: CR report connStr
    ... I designed a CR report from wizard and I had to set a database connection to ... the CR should NOT know anything about a db connection string. ... Dim connectionStrings As ConnectionStringSettingsCollection = ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: ADO connections question
    ... Function CreateADOObjects(ConnectionString as string) ... you'll see this error if the connection has not been ... I have a specific login form that calls the dbLogin function as shown ... Dim strCriteria As String ...
    (microsoft.public.access.adp.sqlserver)