Populate datagrid value from database

  • 16 June 2004
  • 4 replies
  • 0 views

Badge +2
HI. :roll:
I got problem in getting value from database to be displayed in the datagrid. In the K2 process, i've created the XML and i've assigned value from database to the XML in the activity. Then, in the VS.net, ive defined the dataField and the dataXpath for the datagrid, which is the XML. Is there any else that i need to do or what i,ve done is wrong?

One more thing. The time that i assign the database value to the xml field is in the SQL server events, is it 1 sql server event can only use 1 table from databse at one time? Coz my XML for the datagrid need to select value from 2 tables. SO is that means i can use 2 sql server events in 1 activity?


Thanks.

-linda-

4 replies

Badge +7
Perhaps you are not assigning the XML values to the XML datafield in the correct format.
For instance, if your XML data field definition has the following structure:
<Root> 
<LeaveDetails>
<StartDate>01-01-01</StartDate>
<EndDate>03-01-01</EndDate>
<Days>3</Days>
</LeaveDetails>
</Root>

Assuming that you already have the values retrieve from the database stored in variables, you will need to construct the XML structure above in order to have the K2Datagrid display these values correctly. Here's some code to give you a simple idea how it can be done:

Dim strXML as String = ""

strXML += "<Root><LeaveDetails><StartDate>" + startDate + "<StartDate>"
strXML += "<EndDate>" + endDate + "</EndDate>"
......

K2.ProcessInstance.XMLFields.Item("LeaveDetails").Value = strXML

Note: The XML data field should be prepared in an event prior to the client event in your activity.

The SQL Server template can be used to create single/multiple queries via a user friendly "wizard" interface. If you need to have more sophisticated SQL statements that cannot be created via the SQL Server template, you may select "Use code" in the properties of the event and proceed to edit the generated code after the template finishes.
Badge +2
HI samuel.

Yeah i can see that i can retrive the value from the databse already but still cant display into the datagrid yet. I cannot even display the value from the databse to the page even as label or textbox. I just can see the value retrieved in the k2 report page.

Pls help.

-Linda-
Badge +7
XML data fields are not displayed in the pre-SP1 K2.net Workspace reports. Therefore, it should not be related to the problem you are facing. In the new K2.net 2003 SP1, you will be able to view XML data fields in the Process Overview report.

Can you try to verify that using a normal process data field instead of an XML data field to store the database value works? If that approach works, the problem could lie in the way the XML data field is being populated.
Badge +2
yeah.. i've tried using the datafield too, but also doesn't work. :cry:

Reply