|
Below is an example of how to use the DatabaseClient's DatabaseHelper. The example uses the
Northwind database to display the employees in the desired country('USA') in a DataGrid. The
following are the steps taken to get this working in the example.
- Copy the DatabaseClient.dll to the /bin directory.
- Added '<add key="SPextreme.DatabaseClient.ConnectionString" value="PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=C:\\northwind.mdb"/>' to the web.config
- Add '<%@ Import Namespace="DatabaseClient" %>' to the example.aspx page.
- Call the DatabaseHelper method to get the employee data.
<%@ Import Namespace="DatabaseClient" %>
<script language="C#" runat="server">
protected void Page_Load( Object sender, EventArgs e )
{
DataSet data;
Hashtable ht = new Hashtable( );
ht.Add( "@country", "USA" );
data = DatabaseHelper.ExecuteQuery( DatabaseClientType.OLE,
"SELECT * FROM Employees WHERE country = @country", ht );
testGrid.DataSource = data;
testGrid.DataBind( );
}
</script>
<html>
<body>
<asp:DataGrid
id="testGrid"
runat="server"
/>
</body>
</html>
|
|
|
|
|
- Supports SQL Server, Oracle, OLE, and ODBC.
- Supports standard database calls(ExecuteQuery, ExecuteNonQuery, ExecuteScalar).
- Returns queried data in a DataSet.
- Ability to define the connection string in the web.config file.
- DatabaseHelper is a set of static functions to perform any SQL call in a single line of code.
- Separates database interactions from your code.
- Complete documentation.
|
|
|
- Windows
- MS .NET Framework 1.1
|
|
|
|
|
|
|
|
|
|
|
|
|
|