Click here to Skip to main content
15,899,474 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to connect SQLserver Database using text file instead of write system name in sqlconnection in VB.net ?

I am Using Below code to connect Database, But I Dont want to use System name in Datasource and dont want to use System.Environment.MachineName(). I want to use text file here. I want to use System name or server name in that text file, then i call that text file to connect database. Plz help me.

VB
Public SqlConstr As String = "Data Source='" & System.Environment.MachineName() & "';Initial Catalog=ERP_Prod;Persist Security Info=True;"
Posted
Updated 12-Sep-11 19:34pm
v3

1 solution

First of all let me tell you, as general practive Connection String is stored in app.config file for Windows application and in web.config file for web application.

check out
1. Saving Connection Strings to app.config[^]
2. http://msdn.microsoft.com/en-us/library/ms254494(v=vs.80).aspx[^]

for storing and retriving connection string from app.config and web.config.

You can find the connection string for any server at http://www.connectionstrings.com/[^]. This is the best place to generate the connection string.,

Hope this helps.
All the best.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900