Sorry you didnt like it.
I just took the code generated with the creation of the connection string
and replaced the path with the database variable.
xml file loaded at startup provides this info.
The only downside that I have encountered is you can't put it in a module as
I kept getting intialization errors. You might have a thought on that I
could use.
I had to do encryption(the whole string and then grabbing it out of an xml
file) to deal with the password problem in SQL and when one was required in
access but it worked. Sorry for the unnecessary code that is here but it is
what I had opened at the time.
'xml file for user choice of connection
<?xml version="1.0" encoding="utf-8" ?>
<Section Name="Settings">
<Key Name="databasepath" Value="C:\database.mdb"/> 'user fills this when
using open dialog box
</Section>
Loading the file at startup of app....
Private Sub ReadXmlConfig()
' Create Xml Document and load the xml file
Dim xmlDoc As XmlDocument = New XmlDocument
xmlDoc.Load("C:\Neumann Plumbing and Heating\XMLDBPATH.xml") 'can
use appdirectory when finished with project.
' Read mail server value
Dim keyNodeList As XmlNodeList =
xmlDoc.DocumentElement.SelectNodes("Key")
Dim keyNode As XmlNode
For Each keyNode In keyNodeList
' Read the attributes...
Dim attribs As XmlAttributeCollection = keyNode.Attributes
Dim attrib As XmlAttribute = attribs("Name")
If attrib.Value = "databasepaths" Then
databasepath = attribs("Value").Value.ToString()
'MsgBox(databasepath)
End If
Next
End Sub
Using the connection:
Sub GetComboBoxFills()
Dim sConn1 As New OleDb.OleDbConnection
sConn1.ConnectionString = "Jet OLEDB:Global Partial Bulk Ops=2;Jet
OLEDB:Registry Path=;Jet OLEDB
atabase L" & _
"ocking Mode=1;Jet OLEDB
atabase Password=;Data Source=" &
databasepath & _
";Password=;Jet OLEDB:Engine T" & _
"ype=5;Jet OLEDB:Global Bulk
Transactions=1;Provider=""Microsoft.Jet.OLEDB.4.0"";Je" & _
"t OLEDB:System database=;Jet OLEDB:SFP=False;Extended
Properties=;Mode=Share Den" & _
"y None;Jet OLEDB:New Database Password=;Jet OLEDB:Create System
Database=False;J" & _
"et OLEDB
on't Copy Locale on Compact=False;Jet OLEDB:Compact
Without Replica Re" & _
"pair=False;User ID=Admin;Jet OLEDB:Encrypt Database=False"
Dim itemcheck As Integer
Dim dscustomers2 As DataSet 'customer company
'more datasets not relevant here
dscustomers2 = Dscustomers1.Clone
Dim SQL3 As String
'more strings not relevant here
SQL3 = "SELECT DISTINCT CustCompanyName FROM CUSTOMERS order by
CustCompanyName"
dscustomers2.EnforceConstraints = False
Dim OleDbCUSTCOMPANY As New OleDb.OleDbDataAdapter 'customer COMPANY
OleDbCUSTCOMPANY = OleDbDBCUST
OleDbCUSTCOMPANY = New OleDb.OleDbDataAdapter(SQL3, sConn1)
OleDbCUSTCOMPANY.Fill(dscustomers2.Tables(0))
'more fills not relevant here
dscustomers2.AcceptChanges()
sConn1.Close() 'very important