Thursday, July 16, 2009

SQLdatasource Connection String in code behind c#

<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1">

</asp:GridView>

<asp:SqlDataSource ID="SqlDataSource1" runat="server"

ProviderName="System.Data.SqlClient"

DataSourceMode="DataReader"

SelectCommand="SELECT * FROM [mntsold]"></asp:SqlDataSource>

code behind:

SqlDataSource1.ConnectionString =

ConfigurationManager.ConnectionStrings["JDE_PRODUCTIONConnectionString"].ConnectionString;

web.config

<

connectionStrings>

<

add name="JDE_PRODUCTIONConnectionString" connectionString="Data Source=ENTERPRISE;Initial Catalog=JDE_PRODUCTION;User ID=sssss;password=sssss"

providerName="System.Data.SqlClient" />

</
connectionStrings>



No comments: