Download Subsonic
Unpack it somewhere. Open the project . Build it.
Search for the subsonic.dll
@echo off&for /f "tokens=*" %i in ('dir SubSonic.dll /s /b') do echo %i >>list.t
xt&list.txt
In my machine is something like this:
d:\libs\ORM\SubSonic_2.1_Final_Source\src\SubSonicCentral\Bin\SubSonic.dll
Copy this path ( You will need it for pointing the references in the web project ...
Start VS - Start - Run - type "devenv" - Enter
File - new - Project - Web project
Be sure to have the following Web.config structure ( just browse it and copy paste the needd the following lines to your web.config :
<?xml version="1.0"?> <configuration> <configSections> <section name="SubSonicService" type="SubSonic.SubSonicSection, SubSonic"></section> <!-- Your stuff here --> </configSections> <appSettings/> <SubSonicService defaultProvider="Northwind"> <providers> <clear/> <add name="Northwind" type="SubSonic.SqlDataProvider, SubSonic" connectionStringName="Northwind" generatedNamespace="Northwind"/> </providers> </SubSonicService> <connectionStrings> <add name="Northwind" connectionString="Data Source=.;Database=Northwind;Integrated Security=true;"/> </connectionStrings> <system.web> <compilation debug="true"> <buildProviders> <add extension=".abp" type="SubSonic.BuildProvider, SubSonic"/> </buildProviders> <assemblies> <!-- your stuff here --> </assemblies> </compilation> <authentication mode="Windows" /> <pages> <controls> <!-- your stuff here --> </controls> </pages> <httpHandlers> <!-- your stuff here --> </httpHandlers> <httpModules> <!-- your modules here --> </httpModules> </system.web> <system.codedom> <compilers> <!-- compilers stuff --> </compilers> </system.codedom> <system.webServer> <validation validateIntegratedModeConfiguration="false"/> <modules> <!-- your modules --> </modules> <handlers> <!-- your handlers here --> </handlers> </system.webServer> <runtime> <!-- runtime stuff here --> </runtime> </configuration>
Rename the Default page of the project to QuerryWhere ( You would have to rename the inherits="_Default" and the class _Default also in the code behind...
Now paste the following code in the code behind of the QuerryWhere page :
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Reflection; using SubSonic; using System.Data; public partial class QuerryWhere : System.Web.UI.Page { private void CreateDynamicControls() { panGvHolder.Controls.Clear(); Query qry = Northwind.Product.CreateQuery(); qry.Columns.AddRange(Northwind.Product.Schema.Columns); qry.WHERE("UnitPrice > 15").AND("UnitsInStock < 20 "); //WHERE("UnitPrice > 15").AND("UnitsInStock < 30 "); using (IDataReader rdr = qry.ExecuteReader()) { Response.Write("<table>"); while (rdr.Read()) { Response.Write("<tr>"); for (int i = 0; i < rdr.FieldCount; i++) { Response.Write("<td>"); Response.Write(rdr[i].ToString() + " "); Response.Write("<td>"); } //eof for Response.Write("</br>"); Response.Write("</tr>"); } Response.Write("<table>"); } } //eof method #region TemplateMethods protected override void OnInit(EventArgs e) { } //eof OnInit protected override void CreateChildControls() { base.CreateChildControls(); CreateDynamicControls(); } //protected override void CreateChildControls ( ) protected void Page_Load(object sender, EventArgs e) { } protected override object SaveViewState() { return new Pair(base.SaveViewState(), null); } protected override void LoadViewState(object savedState) { base.LoadViewState(((Pair)savedState).First); EnsureChildControls(); } //LoadViewState #endregion //TemplateMethods #region DisplayMethods #endregion //DisplayMethods #region ClickEventHandlers #endregion ClickEventHandlers #region Properties //set here page properties to use with the viewstate #endregion //Properties } //eof class
No comments:
Post a Comment
- the first minus - Comments have to be moderated because of the spammers
- the second minus - I am very lazy at moderating comments ... hardly find time ...
- the third minus - Short links are no good for security ...
- The REAL PLUS : Any critic and positive feedback is better than none, so your comments will be published sooner or later !!!!