Click here to Skip to main content
15,886,570 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello to all
when i add the connection string to web config
have error
when i add the statements
connectionStrings
add name="CS" connectionString="server=192.168.3.34;database=TMTDB;uid=sa;pwd=123"/
/connectionStrings

and can you show me the web config after add this statements
Posted
Updated 20-May-13 22:25pm
v2

 
Share this answer
 
XML
<connectionStrings>
  <add name="ConnectionStringName" connectionString="Data Source=DatabaseServer;Initial Catalog=DatabaseName;User ID=*****;Password=*****" providerName="System.Data.SqlClient"/>
</connectionStrings>
 
Share this answer
 
Below is the basic setting for connection string.
But which database you want to connect, it have some changes for acess/excel
XML
<connectionStrings>
<add name="hhcsnot"  connectionString="Server=database_server_ip;Initial Catalog=databasename;User ID=username;Password=yourpassword"/>
</connectionStrings>


or you can just drag and drop a table from server explorer(connect your database here with studio) in visual studio, It creates automatic a connection string for you...

Thanks
Database Connection String in asp.net[^]
 
Share this answer
 
C#
<connectionstrings>
		<add name="NorthwindConnection" connectionstring="Data Source=.\sqlexpress;integrated security=true;initial catalog=northwind" />
		
	</connectionstrings>
 
Share this answer
 
Comments
ahmed hussein khazal 21-May-13 4:26am    
where i add this statements inside web config
kumar2413 21-May-13 4:32am    
Put it right after configSection
Here is a sample web config file with connection string entry only:
XML
<configuration>
  <appsettings />
  <connectionstrings>
    <add name="SqlConnection" connectionstring="Server=YourServerName;Database=YourDatabaseName;User ID=*****;Password=*****;" providername="System.Data.SqlClient" />
  </connectionstrings>
  <system.web>
    <compilation debug="true">
    </compilation>
    <authentication mode="None" />
  </system.web>
</configuration>
 
Share this answer
 
Comments
ahmed hussein khazal 21-May-13 4:44am    
thank you Zafar
can you show me the standard web config of web project visual studio after add the connection string
Zafar Sultan 21-May-13 5:53am    
The above is a web config file from one of my project. There were other entries in it but for the sake of understanding and keeping it more readable I have omitted that. You can include only this part in your config file and it will work. The other entries in the config file are usually for namespaces, ajax, smtp settings, web service references etc.
Can U Post The Error That What Error Its Showing
 
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