Using the ADO.net Provider

K2 blackpoint ships with an ADO.net provider for interacting with SmartObjects.  This includes any SmartObjects that you create against SharePoint content, Workflow SmartObjects that you can configure when designing your process, as well as some pre-configured reporting SmartObjects which are used by the out of the box reports in the process portal.

The ADO.net provider allows you to build ASP.net forms as well as SQL Reporting Services reports in much the same way as you would use any other ADO.net provider.

 

Today I will show you the ASP.net example.  The recording attached to this post also discusses using the ADO.net Provider in a SQL Reporting Services report.  The configuration of the data source is similar for ASP.net and SQLRS.

For this example I have created a basic web page project.  There are 2 things that you will need to configure to ensure that your ASP.net page works properly with the data provider:

  • Turn on Integrated Authentication for the web application in IIS and turn off anonymous access.  This can be done in the Authentication and Access control section of the Directory Security tab in the Web Application properties.

image

  • Add the following line to your web.config file:

<identity impersonate="true"/>

In Visual Studio the ADO.net controls are in the standard toolbox under the Data section

image

Drag the SQLDataSource object on to your page.

image

In the configuration of the SQLDataSource click new connection.

image

On the Add Connection Dialog click Change to select a different data source.  Choose the K2 Smartobjects data source and click OK.

image

Select your Server Name and Port and then click the ellipses next to selected SmartObjects.

image

This will bring up a browser that allows you to select the SmartObject(s) that you would like to use. Once you have made your selection click OK.

image

The next section asks you how you would like to retrieve the data.  The SmartObject data source exposes the methods as stored procedures so select the stored procedures option and click next.

image

For each tab (Select, Update, Insert, and Delete) select the corresponding stored procedure from the drop down list.  For select you can either use the get list method or the load method.  In this example I want to retrieve all the records so I am selecting the get list method.

image

Once you finish the rest of the wizard you will now be able to use the other ADO.net controls, such as the Grid View, to view and manipulate the data coming from the SmartObject.

image

If you used the Get List option for the Select statement make sure to turn CancelSelectOnNullParameter to False in the properties for the data source otherwise you will not get any results back.

image

Here is an example page for viewing an announcements list from SharePoint in an ASP.net page using the ADO.net provider.  I also added a details view that allows me to add items to the list as well.

image

If you would like to see this example and a SQL Reporting Services example in action please refer to the recording attached to this post.


Posted Fri, Apr 17 2009 3:24 PM by k2eric

Comments

sptest09 wrote re: Using the ADO.net Provider
on Wed, Feb 24 2010 11:55 AM

Is there any sample for using SourceCode.Data.SmartObjectsClient DLL to do what you do?

k2eric wrote re: Using the ADO.net Provider
on Thu, Mar 4 2010 9:36 AM

The K2 blackpoint licensing agreement restricts you from making use of the SmartObjectClient API.  That API is only available in K2 blackpearl.  The developer SDK for K2 blackpearl on http://help.k2.com has some examples of accessing SmartObject programmatically

jes wrote re: Using the ADO.net Provider
on Wed, Mar 24 2010 3:27 AM

Can you help me? i'm creating asp.net forms, i want to programmatically Add Records to a SmartObject.

mei.wei wrote re: Using the ADO.net Provider
on Tue, May 25 2010 8:45 AM

This is a great article. I was able to create a report following the steps. But how can I get the worklist item's status (Open/Available) through the ado query?