1. Menu add connection strings in c:\inetpub\wwwroot\wss\VirtualDirectories\
Ex.
/* for sql server and oracle*/
<connectionStrings>
<add name="AdventureWorksConnectionString" connectionString="Data Source=192.168.0.1;Initial Catalog=AdventureWorks;User Id=sa;Password=smpsqladm1" />
<add name="OracleConnectionString" connectionString="Data Source=Ora_TEST;User ID=system;Password=system_pwd" providerName="System.Data.OracleClient" />
</connectionStrings>
2. In Sharepoint virtual web part ascx file .
<asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="125px"
DataSourceID="SqlDataSource1" EnableModelValidation="True">
</asp:DetailsView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:AdventureWorksConnectionString%>"
SelectCommand="select count(*) as intUnRead from yourtable">
</asp:SqlDataSource>
<asp:DetailsView ID="DetailsView2" runat="server" Height="50px" Width="125px"
DataSourceID="SqlDataSource2" EnableModelValidation="True">
</asp:DetailsView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:OracleConnectionString %>"
ProviderName="System.Data.OracleClient"
SelectCommand="select count(*) as UnRead from testtable">
</asp:SqlDataSource>
Nov 2, 2010
Sharepoint 2010 connect to sql server and oracle database
張貼者: Brian 於 14:15
標籤: Sharepoint 2010
Subscribe to:
Post Comments (Atom)
0 意見:
Post a Comment