0
hi,
As iftikar said you create a Data access layer and get that connection string into that from web.config and use it in any page by creating object of that class.
0
better create one DataAccess layer and defined your connection over there. So that this DAL can be used throughout your project for any sql operation
Regards,
Iftikar
0
Nothing required just declare the connection string in web.config like this
<connectionStrings>
<add name="dbconnection" connectionString="Data Source=SureshDasari;Integrated Security=true;Initial Catalog=MySampleDB" providerName="System.Data.SqlClient"/>
</connectionStrings >
then which page you want connection string !st add the reference
Imports System.Configuration
then you can able to get the connection string in page like this
Dim strcon As String = ConfigurationManager.ConnectionStrings("dbconnection").ConnectionString
now you can use it
0
Hi,
Can we write it as something like master page function after declaring in web.config file, to use like function in sub pages
Or in Function in Dll
I hope M clear
0
0
Hi,
You no need to declare you connection string again and again until it is different for sub page. Just declare once in your main web.config
<connectionStrings>
<add name="conString"
connectionString="Data Source=SQLEXPRESS;Initial Catalog=MyDb;Persist Security Info=True;User ID=MyUserId;Password=MyPassword"
providerName="System.Data.SqlClient" />
</connectionStrings>
Regards,
Iftikar