You need to sign in to do that
Don't have an account?
EdgeLine
Grid Control: sql datasource [connect] to salesforce in easy manner?
I realise this will come across as a very naive question. I wish to quickly and effectively utilize the inbuilt functionality of the asp.net GRID or 'sql data source' control which allows you to visually connect to a underlying sql server database.
Is it possible to somehow replace the sql server assignment below with a connection to salesforce? I have messed around with wsdl 'loginresult' etc but it is very unclear to me as to how to tie in the grid control quickly and easily to salesforce. Here is snapshot of typical grid control source code:
Code:
There is no clear example in the KB on how to do this. Any straightword code examples or explanations would be very much appreciated.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT * FROM [Customer]"></asp:SqlDataSource> </div> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="CustomerID" DataSourceID="SqlDataSource1" Style="z-index: 100; left: 54px; position: absolute; top: 78px"> <Columns> <asp:BoundField DataField="CustomerID" HeaderText="CustomerID" InsertVisible="False" ReadOnly="True" SortExpression="CustomerID" /> <asp:BoundField DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" /> <asp:BoundField DataField="LastName" HeaderText="LastName" SortExpression="LastName" /> <asp:BoundField DataField="CustomerSince" HeaderText="CustomerSince" SortExpression="CustomerSince" /> <asp:BoundField DataField="CreditLimit" HeaderText="CreditLimit" SortExpression="CreditLimit" /> </Columns> </asp:GridView> </form> </body> </html>
There is no clear example in the KB on how to do this. Any straightword code examples or explanations would be very much appreciated.
Thanks
Edgeline
ps: Yes, I know I need to buy some .asp net books and teach myself before anyone offers me this advice again :)
Message Edited by SimonF on 08-21-2006 02:47 PM
sforce.QueryResult qr = svc.query("select id, name, accountNumber from Account");
dg.DataSource = qr.records;
dg.DataBind();
This is the standard object data binding support in .NET.
Thanks, Simon, I finally extracted data out of sales force using a .net visual grid control doing the databinding in the .cs file in the page load event.
Depending on what you query we'll reduce the # of rows returned to keep the response message size within managable limits for the client soap stack (if you have 1M rows, you don't want them all in one go). you can call queryMore to get the next set of rows (see the API docs & samples).
The <columns> XML attributes will override the default "show everything" behavior.
2. There is obviously a performance hit to use this control...it is slooow roughly 17 seconds to load.
Correct. Best practice is to asynchronously replicate and cache Salesforce records for use in low latency web sites.
3. Strangely enough it only pulls out about 200 records...there must be some limit to the control?
Correct. Saleforce will return records 200 at a time and indicate there are more records to be retrieved by setting the queryResult.done flag to false.
Here is one approach (in C#) to retrieving all records.