USE

USE tells the Connector to switch SharePoint site for subsequent statements. The specified site remains selected until the SharePointConnection is reused or another USE statement is issued.

Syntax

USE list_name;

The USE statement is provided as a quick way to change site without having to change the connection string and open a new SharePointConnection.

Example: to change to the site Marketing/Material:

USE `Marketing/Material`;

Code examples

Change site and list shared documents

using (var connection = new SharePointConnection(connectionString))
{
    connection.Open();
    using (var command = new SharePointCommand(@"USE `sites/demo`", connection))
    {
        command.ExecuteNonQuery();
    }

    using (var command = new SharePointCommand("SELECT ServerUrl, Modified FROM `Shared Documents`", connection))
    {
        using (var reader = command.ExecuteReader())
        {
            while (reader.Read())
            {
                Console.WriteLine(reader["ServerUrl"].ToString().PadRight(40) + " : " + reader["Modified"].ToString());
            }
        }
    }
}

Code result

Images                                   : 2012-04-19 23:29:37
Images/bendsoft.jpg                      : 2012-04-19 23:49:46


Skip Navigation Links.

Visa     MasterCard