Copy Code code as follows:
Using System;
Using System.Data;
Using System.Configuration;
Using System.Web;
Using System.Web.Security;
Using System.Web.UI;
Using System.Web.UI.WebControls;
Using System.Web.UI.WebControls.WebParts;
Using System.Web.UI.HtmlControls;
Using CrystalDecisions.CrystalReports.Engine;
Using Crystaldecisions.shared;
Using System.Data.Common;
<summary>
Summary description of Orderinfoconfiguration
</summary>
public class Orderinfoconfiguration
{
Private Const string connectionstring=@ "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\program files\ Tutorialsamplecodeprojects\xtreme.mdb ";
Private Const string querystring= "SELECT a.[order Date" As Order time, A.[order ID] As order number, B.[last name]+\ "\" +b.[first Name] As Employee name, C.[customer name] as customer name, d.[product name] as product name from Orders a,employee B,customer c,product D, [Orders Detail] e WH ERE a.[employee id]=b.[employee id] and A.[customer id]=c.[customer ID] and a.[order id]=e.[order ID] and e.[product ID]=d . [Product ID];
public static DataSet Orderinfodataset
{
Get
{
DataSet DataSet = new DataSet ();
DbProviderFactory factory = dbproviderfactories.getfactory ("System.Data.OleDb"); Get Factory
DbConnection con = factory. CreateConnection ();//Create Connection
Con. ConnectionString = ConnectionString;
DbCommand cmd = factory. CreateCommand ();//create command
Cmd.commandtext = querystring;
Cmd.commandtype = CommandType.Text;
Cmd. Connection = con;
DbDataAdapter Dapter = Factory. Createdataadapter ();//Create Adapter
Dapter. SelectCommand = cmd;
Dapter. Fill (dataSet);/
return dataSet;
}
}
Public Orderinfoconfiguration ()
{
//
TODO: Add constructor logic here
//
}
}
DbProviderFactory factory = dbproviderfactories.getfactory ("System.Data.OleDb"); Get a factory and you can use the factory to produce a variety of objects for the data provider.
If the connection
Sqlserver:dbproviderfactory factory = dbproviderfactories.getfactory ("System.Data.SqlClient");
Oracle:dbproviderfactory factory = dbproviderfactories.getfactory ("System.Data.OracleClient");
Odbc:dbproviderfactory factory = dbproviderfactories.getfactory ("System.Data.Odbc");
Use this, if want to change a database, is it very convenient? Oh.