Hi Friends :cool: Am creating a personal diary application using VB.Net. When i publish the solution i get the .exe file. But when i install it, it gets installed in the C drive by default.
My question is cant it be installed in someother drive. If it cant someone pls tel me the way to change the location of the database from the default C drive.

>My question is cant it be installed in someother drive. If it cant someone pls tel me the way to change the location of the database from the default C drive.

Store database connection in app.config file and read it programatically.

1. Add app.config in your project (Application Configuration file.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <connectionStrings>
    <add name="CnStr"
          providerName="System.Data.OleDb"
          connectionString="put_here_your_connection_string"
         />
  </connectionStrings>
    <system.diagnostics>
         ..........
         .........
</configuration>

To read connection string,

1. Add the reference of System.Configuration
2. Use following code,

str=System.Configuration.ConfigurationManager.ConnectionStrings("CnStr").ConnectionString

thanks for the reply. But i hav already added the app.config file to the application. where should i add the sys.config code ?

System.Configuration.DLL is library file and you have to add the reference of this library into your project.

ya its working. but wats the use of the code which u gave ? Where ll the application be installed ? i dont want it to be installed in C drive

>Where ll the application be installed ?

At any drive and folder.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.