|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
ConnectionStringCon.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 "No_So_Clever" <NOSPAM@NOSPAM.net> wrote in message There is no fix because there's nothing wrong - your code is returning you 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? 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. 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 > > > > 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 >> >> >> >> > > |
|||||||||||||||||||||||