Database Client Example

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.

  1. Copy the DatabaseClient.dll to the /bin directory.
  2. Added '<add key="SPextreme.DatabaseClient.ConnectionString" value="PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=C:\\northwind.mdb"/>' to the web.config
  3. Add '<%@ Import Namespace="DatabaseClient" %>' to the example.aspx page.
  4. 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>

Features
  • 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.
System Requirements
  • Windows
  • MS .NET Framework 1.1
Support
Purchase
Download

 

Copyright 2004 SPextreme.com. All rights reserved