Calling Stored Procedures
You can invoke a stored procedure using SharePointCommand in the same way as any other SQL stored procedure. To instantiate a SharePointCommand, provide the name of the stored procedure and a SharePointConnection instance as arguments to the constructor. Set the CommandType property to StoredProcedure and add the parameters as key-value pairs to the Parameters collection of the SharePointCommand instance.
string connectionString = "user=myuseraccount;password=mypassword;URL=http://sharepointserver/mysite;Offline=false;";
SharePointConnection conn = new SharePointConnection(connectionString);
SharePointCommand cmd = new SharePointCommand("DownloadDocument", connection);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SharePointParameter("@File", "MyFile.txt"));
// Add other parameters as needed ...
SharePointDataReader rdr = cmd.ExecuteReader();
while (rdr.Read()) {
for (int i = 0; i < rdr.FieldCount; i++) {
Console.WriteLine(rdr.GetName(i) + " --> " + rdr[i]);
}
Console.WriteLine();
}