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();
}
}