How easy is to use the SqlNetFramework?
The purpose of the following walkthrough is to demonstrate how quick and easy
is to execute SQL statements using the SqlNetFramework. We will use the SqlStoreDataSource
control included in the SqlNetFramework, a GridView control and an Access database
to display data.
Configuring the AssemblyInfo file to specify the application type (Windows Forms or ASP.NET).
[assembly: ApplicationSettings(ApplicationType.Web)]
Configuring the web.config file to work with an access database.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="connections" type="..."/>
<section name="dbFactories" type="..."/>
<section name="sqlDataStores" type="..."/>
<section name="sqlDataStoreManagers" type="..."/>
</configSections>
<connections>
<connection
id="Neptuno"
connectionString="PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE='C:\Neptuno.mdb';"
dbFactoryId="OleDbFactory"
sqlDataStoreId="NeptunoXmlDataStore"/>
</connections>
<sqlDataStores>
<sqlDataStore
id="NeptunoXmlDataStore"
sqlDataStoreManager="XmlSqlDataStoreManager"
connectionSettings="File=C:\NeptunoQuerys.xml|ResourceLocation=File"
sqlDataCacheMode="All"/>
</sqlDataStores>
</configuration>
Using a XML file to store the SQL statements. The XML content is generated by the SqlEditor that comes with the SqlNetFramework.
<XmlSqlDataStore xmlns="http://tempuri.org/XmlSqlDataStore.xsd">
<SqlStatement>
<SqlStatementId>1</SqlStatementId>
<SqlStatementName>All clients</SqlStatementName>
<Description />
<CommandText><![CDATA[SELECT * FROM Clients]]></CommandText>
<SqlStatementType>Text</SqlStatementType>
<LastModification>2006-12-05T00:00:00-06:00</LastModification>
</SqlStatement>
</XmlSqlDataStore>
Using a SqlStoreDataSource control as data source for a GridView control.
<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlStoreDataSource1">
</asp:GridView>
<SqlNetFramework:SqlStoreDataSource ID="SqlStoreDataSource1" runat="server"
ConnectionID="Neptuno" DataSourceMode="DataSet" SelectStatementID="1">
</SqlNetFramework:SqlStoreDataSource>
Viewing the result in the web browser.
As you can see the SQL statements are no included in your ASP.NET ASPX file. You can use your SQL statements in multiple .NET applications such as: Windows Forms and ASP.NET.