You need to sign in to do that
Don't have an account?
nbk
How to insert data from Dot Net webpage to Salesforce
Hi All,
Here is my requirement.
I have one simple dot net webform, it contains 2 text fileds (Name, WebSite) and Submit Button.
If I hit submit button new record will be created on Account object (Salesforce) with Name and Website fields.
Can you please give me ideas to acheive above requirement.
Thanks,
Krishna
you can do this using the salesforce API. Add the salesforce partner or enterprise API in your dot net project as a reference. And then you should be able to insert or update the account record.
Hi,
Generate either Enterprise or partner WSDL. (Develop -> API -> generate Enterprise WSDL)
Add that WSDL file to web references in your .net application.
After that in ASP.net web page try to implement below logic.
----------------
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using WebApplication3.devWsdl;
namespace WebApplication3
{
public partial class _Default : System.Web.UI.Page
{
SforceService svc = new SforceService();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindContacts();
}
}
public bool IsSFDCLogin()
{
try
{
LoginResult objLoginResultr = svc.login("narasimha@gmail.com", "lakshmi@123lLzsm8ORK3tUxaJrUEoXKIop6");
SessionHeader objSessionHeader = new SessionHeader();
objSessionHeader.sessionId = objLoginResultr.sessionId;
svc.SessionHeaderValue = objSessionHeader;
svc.Url = objLoginResultr.serverUrl;
return true;
}
catch (Exception ex)
{
return false;
}
}
private void BindContacts()
{
DataTable dt = new DataTable();
dt.Columns.Add("Name");
dt.Columns.Add("LastName");
dt.Columns.Add("Phone");
dt.Columns.Add("Email");
dt.Columns.Add("Fax");
dt.Columns.Add("Id");
dt.AcceptChanges();
if (IsSFDCLogin())
{
var objResult = svc.query("select id,name,LastName,Phone,Email,Fax from contact");
if (objResult.size > 0)
{
for (int i = 0; i < objResult.size; i++)
{
DataRow dr = dt.NewRow();
dr["Id"] = ((Contact)(objResult.records[i])).Id;
dr["Name"] = ((Contact)(objResult.records[i])).Name;
dr["LastName"] = ((Contact)(objResult.records[i])).LastName;
dr["Phone"] = ((Contact)(objResult.records[i])).Phone;
dr["Email"] = ((Contact)(objResult.records[i])).Email;
dr["Fax"] = ((Contact)(objResult.records[i])).Fax;
dt.Rows.Add(dr);
}
dt.AcceptChanges();
gvTest.DataSource = dt;
gvTest.DataBind();
}
}
}
}
}
Hi,
You can achieve this using Salesforce.com API , get the Salesforce.com API and generate WSDL file from this as this WSDL file to reference section of your .NET application, now you can access the Salesforce from you .NET Application.