Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 986
  • Last Modified:

Microsoft Visual C# Database and UNC path

Hi Experts, I am using a database connection string: "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\TransportScheduling_be.mdb"

How do I convert the connection string to a UNC path? The network drive letter is U:\.....

Thanx in advance
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\TransportScheduling_be.mdb"

Open in new window

0
Benvor
Asked:
Benvor
  • 3
  • 3
1 Solution
 
DhaestCommented:
Do you want to hardcode to the u-drive ?

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=u:\TransportScheduling_be.mdb"
0
 
BenvorAuthor Commented:
No i don't want to hardcode the drive, for if the network drive should change, so if the network drive should change it must automatically search for an alternative drive with the "TransportScheduling_be.mdb" inside
0
 
DhaestCommented:
How does the program know where to search for the database than ? Do you want to enumerate through all the drives on the pc or even on the network ?
I won't do that, but leave the settings in the .config-file and if the network path changes, just adjust the config-file
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
BenvorAuthor Commented:
Can you please help me to import the connection string(settings) from the .config-file into the programs connection string?
0
 
DhaestCommented:
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["SecurityServerConnStr"]);

and your config should be the following

<configuration>
      <appSettings>
            <add key="SecurityServerConnStr" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=u:|\TransportScheduling_be.mdb"/>
      </appSettings>
0
 
BenvorAuthor Commented:
Thanx allot Dhaest
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now