Home All Groups Group Topic Archive Search About
Author
15 Nov 2005 5:45 PM
No_So_Clever
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

Author
15 Nov 2005 6:04 PM
Mark Rae
"No_So_Clever" <NOSPAM@NOSPAM.net> wrote in message
news:gs-dnfLLM8rMg-feSa8jmw@karoo.co.uk...

> 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?

There is no fix because there's nothing wrong - your code is returning you
PRECISELY what you asked for.

SelectedIndex returns an integer representing the element of the Items array
which is currently selected - nothing whatever to do with the value or text
of that Item. If you populate a combobox with the twelve months of the year
in chronological order (i.e. January, February, March etc) and select
December, the SelectedIndex will be 11.

Put a breakpoint on the above line and then interrogate Me.cboSelectDB in
the Command window - you'll soon see which property you need.
Author
19 Dec 2005 3:18 PM
Cor Ligthert [MVP]
No_So_Clever

Try SelectedValue

I hope this helps,

Cor


Show quote
"No_So_Clever" <NOSPAM@NOSPAM.net> schreef in bericht
news:gs-dnfLLM8rMg-feSa8jmw@karoo.co.uk...
> 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
>
>
>
>
Author
19 Dec 2005 4:04 PM
W.G. Ryan - MVP
Cor:

I'm not following you here, where does SelectedValue fit in?
Show quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
news:uHhZZ9KBGHA.2692@TK2MSFTNGP10.phx.gbl...
> No_So_Clever
>
> Try SelectedValue
>
> I hope this helps,
>
> Cor
>
>
> "No_So_Clever" <NOSPAM@NOSPAM.net> schreef in bericht
> news:gs-dnfLLM8rMg-feSa8jmw@karoo.co.uk...
>> 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
>>
>>
>>
>>
>
>

AddThis Social Bookmark Button