Camelot .NET Connector and SqlDataSource

One of the most common examples of  databinding in ASP.NET is how to use the SqlDataSource control to connect to an underlying SQL data source. This is also a great way to show the simpleness that comes with the Camelot .NET Connector for Microsoft SharePoint and integration with MOSS/WSS. The SqlDataSource control uses ADO.NET classes to interact with any database supported by ADO.NET.

When you configure the SqlDataSource control, you use the ProviderName property to identify the database that you want to connect to (in our case Camelot.SharePointConnector) and the ConnectionString property to set the connection string required to connect to MOSS/WSS.

Example: Using the connector with SqlDataSource to populate a DropDownList

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head id="Head1" runat="server">
    <title>ASP.NET DropDown Example</title>
</head>
<body>
    <form id="form2" runat="server">

      <asp:SqlDataSource
          id="SqlDataSource1"
          runat="server"
          ProviderName="Camelot.SharePointConnector"
          DataSourceMode="DataReader"
          ConnectionString="Server=demo.bendsoft.com;Domain=;User=spuser;Password=sppwd;Authentication=Ntlm;"
          SelectCommand="SELECT ID, Name FROM Employees">
      </asp:SqlDataSource>

      <asp:DropDownList
          id="ListBox1"
          runat="server"
          DataValueField="ID"
          DataTextField="Name"
          DataSourceID="SqlDataSource1">
      </asp:DropDownList>

    </form>
  </body>
</html>

This entry was posted in SharePoint. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>