PDA

View Full Version : Linking the connectionstring in webconfig


shinigaimi
23-06-2007, 22:29
I want to connect to the SQL Server Express through the webconfig of the ConnectionStrings to the VB.net 2005 .I only know how to connect to aspx file. Any idea what is the connection string in vb code itself ?


--Webconfig file--
<connectionStrings>
<add name="adminsdb" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=.\admins.mdf; Integrated Security=True;"
providerName="System.Data.SqlClient" />
</connectionStrings>

----aspx file ---
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:adminsdb %>"
ProviderName="<%$ ConnectionStrings:adminsdb.ProviderName %>" SelectCommand="SELECT [Password] FROM [Administrators]">
</asp:SqlDataSource>


vb code Any Idea ? I tried the Public stConnectionString As String = ConfigurationSettings.AppSettings("ConnectionString") type of method it won't work since this is for the <appSettings> so what is the vb code for the <connectionStrings> part ?