Pull Method (String, String, String, RdaTrackOption)

Downloads data from a remote database and stores that data in a single table in a local database.

Namespace:  System.Data.SqlServerCe
Assembly:  System.Data.SqlServerCe (in System.Data.SqlServerCe.dll)

Syntax

'Declaration
Public Sub Pull ( _
    localTableName As String, _
    sqlSelectString As String, _
    oleDBConnectionString As String, _
    trackOption As RdaTrackOption _
)
'Usage
Dim instance As SqlCeRemoteDataAccess
Dim localTableName As String
Dim sqlSelectString As String
Dim oleDBConnectionString As String
Dim trackOption As RdaTrackOption

instance.Pull(localTableName, sqlSelectString, _
    oleDBConnectionString, trackOption)
public void Pull(
    string localTableName,
    string sqlSelectString,
    string oleDBConnectionString,
    RdaTrackOption trackOption
)
public:
void Pull(
    String^ localTableName, 
    String^ sqlSelectString, 
    String^ oleDBConnectionString, 
    RdaTrackOption trackOption
)
member Pull : 
        localTableName:string * 
        sqlSelectString:string * 
        oleDBConnectionString:string * 
        trackOption:RdaTrackOption -> unit 
public function Pull(
    localTableName : String, 
    sqlSelectString : String, 
    oleDBConnectionString : String, 
    trackOption : RdaTrackOption
)

Parameters

  • localTableName
    Type: System. . :: . .String
    The name of the table that will receive the extracted records. An error occurs if the table already exists.
  • sqlSelectString
    Type: System. . :: . .String
    Any valid Transact-SQL statement—including SELECT statements and stored procedures—that specifies which table, columns, and records to extract from the database for storing in the database.
  • trackOption
    Type: System.Data.SqlServerCe. . :: . .RdaTrackOption
    The option indicating whether tracks changes made to the pulled table, and whether the indexes that exist on the table being pulled are brought down to the device with the PRIMARY KEY constraints.

Remarks

The InternetLogin and InternetPassword properties must be specified if the virtual directory that contains the Server Agent is configured to use Basic authentication or Integrated Windows authentication. sqlSelectString controls which data is pulled from the table. An error occurs if the resulting recordset contains an unsupported data type, such as Timestamp. sqlSelectString can specify a WHERE clause to control which records are returned. For example, SELECT * FROM Customers WHERE State='CA' would retrieve customers who live in California only. sqlSelectString also supports row-returning stored procedures or views. It can also pull selected columns from multiple tables into a single table when using the TrackingOff option.

If Authentication is used, the user ID specified in OLEDBConnectionString must have the authority to read the table.

If Windows Authentication is used by setting INTEGRATED SECURITY="SSPI" in OLEDBConnectionString, the Internet user must have the authority to read the table. The following identifies the Internet user based on the authentication method:

  • When Internet Information Services (IIS) virtual directory is configured to use anonymous access, the Internet user runs under the identity of the Internet Guest Account (IUSR_computername). If you configure another Windows user account as the Internet Guest Account, the Internet user runs under the identity of that account.

  • When IIS virtual directory is configured to use Basic authentication, the Internet user runs under the identity of the Windows user account for which the client supplied the Internet user name and password.

  • When IIS virtual directory is configured to use Integrated Windows authentication, the Internet user runs under the identity of the Windows user account for which the client supplied the Internet user name and password.

For more information about data access and limitations, see "Supported Data Types and Data Type Mappings" and "RDA Limitations" in Books Online.

Examples

The following example creates a SqlCeRemoteDataAccess object, sets several properties, and then calls the Pull method.

' Connection String to the SQL Server
'
Dim rdaOleDbConnectString As String = "Data Source=MySqlServer;Initial Catalog=AdventureWorks; " & _
    "User Id=username;Password = <password>"

' Initialize RDA Object
'
Dim rda As SqlCeRemoteDataAccess = Nothing

Try
    ' Try the Pull Operation
    '
    rda = New SqlCeRemoteDataAccess( _
        "https://www.adventure-works.com/sqlmobile/sqlcesa35.dll", _
        "MyLogin", _
        "<password>", _
        "Data Source=MyDatabase.sdf")

    rda.Pull("Employees", "SELECT * FROM DimEmployee", rdaOleDbConnectString, _
        RdaTrackOption.TrackingOnWithIndexes, "ErrorTable")

    ' or, try one of these overloads:
    ' rda.Pull("Employees", "SELECT * FROM DimEmployee", rdaOleDbConnectString, _
    '     RdaTrackOption.TrackingOnWithIndexes)
    '
    ' rda.Pull("Employees", "SELECT * FROM DimEmployee", rdaOleDbConnectString)

Catch
    ' Handle errors here
    '
Finally
    ' Dispose of the RDA object
    '
    rda.Dispose()
End Try
// Connection String to the SQL Server
//
string rdaOleDbConnectString = "Data Source=MySqlServer;Initial Catalog=AdventureWorks; " +
    "User Id=username;Password = <password>";

// Initialize RDA Object
//
SqlCeRemoteDataAccess rda = null;

try
{
    // Try the Pull Operation
    //
    rda = new SqlCeRemoteDataAccess(
        "https://www.adventure-works.com/sqlmobile/sqlcesa35.dll",
        "MyLogin",
        "<password>",
        "Data Source=MyDatabase.sdf");

    rda.Pull("Employees", "SELECT * FROM DimEmployee", rdaOleDbConnectString,
        RdaTrackOption.TrackingOnWithIndexes, "ErrorTable");

    // or, try one of these overloads:
    //
    // rda.Pull("Employees", "SELECT * FROM DimEmployee", rdaOleDbConnectString,
    //     RdaTrackOption.TrackingOnWithIndexes);
    //
    // rda.Pull("Employees", "SELECT * FROM DimEmployee", rdaOleDbConnectString);
}
catch (SqlCeException)
{
    // Handle errors here
    //
}
finally
{
    // Dispose of the RDA object
    //
    rda.Dispose();
}

See Also

Reference

SqlCeRemoteDataAccess Class

SqlCeRemoteDataAccess Members

Pull Overload

System.Data.SqlServerCe Namespace