SalesforceConnection Class
Represents an open connection to Salesforce.com or Database.com.
The following example creates a
SalesforceCommand and a
SalesforceConnection. The
SalesforceConnection is opened and set as the
Connection property. The example then calls
ExecuteNonQuery method, and closes the connection. To accomplish this, the
ExecuteNonQuery is passed a connection string and a query string that is SQL INSERT statement.
public void InsertRow(string salesforceConnectionString)
{
// If the connection string is empty, use default.
if(salesforceConnectionString == "")
{
salesforceConnectionString = "Server=login.salesforce.com;User [email protected];
Password=mypassword;Security Token=qweASDzcx1234567890rtyui;";
}
SalesforceConnection myConn = new SalesforceConnection(salesforceConnectionString);
string myInsertQuery = "INSERT INTO Account(Name) Values('New account')";
SalesforceCommand salesforceCommand = new SalesforceCommand(myInsertQuery);
salesforceCommand.Connection = myConn;
myConn.Open();
try
{
salesforceCommand.ExecuteNonQuery();
}
finally
{
myConn.Close();
}
}
public void InsertRow(string salesforceConnectionString)
{
// If the connection string is empty, use default.
if(salesforceConnectionString == "")
{
salesforceConnectionString = "Server=login.salesforce.com;User [email protected];" & _
"Password=mypassword;Security Token=qweASDzcx1234567890rtyui;";
}
SalesforceConnection myConn = new SalesforceConnection(salesforceConnectionString);
string myInsertQuery = "INSERT INTO Account(Name) Values('New account')";
SalesforceCommand salesforceCommand = new SalesforceCommand(myInsertQuery);
salesforceCommand.Connection = myConn;
myConn.Open();
try
{
salesforceCommand.ExecuteNonQuery();
}
finally
{
myConn.Close();
}
}
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2