Condividi tramite


SqlCeRemoteDataAccess.Pull Method (String, String, String, RdaTrackOption, String)

Note: This namespace, class, or member is supported only in version 1.1 of the .NET Framework.

Extracts data from a SQL Server database and stores it in a table in a SQL Server CE database.

  [Visual Basic]
  Overloads Public Sub Pull( _
   ByVal 
  localTableName
   As String, _
   ByVal sqlSelectString As String, _
   ByVal oledbConnectionString As String, _
   ByVal trackOption As RdaTrackOption, _
   ByVal errorTable As String _
)
[C#]
public void Pull(string localTableName,string sqlSelectString,string oledbConnectionString,RdaTrackOption trackOption,string errorTable
);
[C++]
public: void Pull(String* localTableName,String* sqlSelectString,String* oledbConnectionString,RdaTrackOption trackOption,String* errorTable
);
[JScript]
public function Pull(
   localTableName : String,
 sqlSelectString : String,
 oledbConnectionString : String,
 trackOption : RdaTrackOption,
 errorTable : String);

Parameters

  • localTableName
    The name of the SQL Server CE table that will receive the extracted SQL Server records. An error occurs if the table already exists.
  • sqlSelectString
    Any valid Transact-SQL statement, including SELECT statements and stored procedures, that specifies which table, columns, and records to extract from the SQL Server database for storing in the SQL Server CE database.
  • oledbConnectionString
    The OLE DB connection string used when connecting to the SQL Server database.
  • trackOption
    The option indicating whether SQL Server CE tracks changes made to the pulled table and if the indexes that exist on the table being pulled are brought down to the device with the PRIMARY KEY constraints.
  • errorTable
    The name of the local error table that is created if an error occurs when the Push method is later called to send changes back to SQL Server. This option can be specified only when the RdaTrackOption value is TrackingOn or TrackingOnWithIndexes.

Remarks

The InternetLogin and InternetPassword properties must be specified if the virtual directory that contains the SQL Server CE Server Agent is configured to use Basic authentication or Integrated Windows authentication. sqlSelectString controls which data is pulled from the SQL Server 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 SQL Server Authentication is used, the user ID specified in OLEDBConnectionString must have the authority to read the SQL Server table.

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

  • When Microsoft 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 the SQL Server CE Books Online.

Example

  [Visual Basic] 
' Connection String to the SQL Server.
Dim rdaOleDbConnectString As String = _
    "Provider=sqloledb; Data Source=MySqlServer;Initial Catalog=Northwind; " + _
    "User Id=username;Password = <password>"

' Initialize RDA Object.
Dim rda As SqlCeRemoteDataAccess = Nothing

Try
    'Try the Pull Operation.
    rda = New SqlCeRemoteDataAccess()
   
    rda.InternetLogin         = "MyLogin"
    rda.InternetPassword      = "<password>"
    rda.InternetUrl           = "<http://www.northwindtraders.com/sqlce/sscesa20.dll>"
    rda.LocalConnectionString = "Provider=Microsoft.SQLSERVER.OLEDB.CE.2.0;Data Source=\ssce.sdf"
   
    rda.Pull("Employees", "Select * from Employees", _
       rdaOleDbConnectString, _
       RdaTrackOption.TrackingOnWithIndexes, _
       "ErrorTable")

Catch e As SqlCeException
'Use you own Error Handling Routine.
'ShowErrors(e);
Finally
   'Dispose of the RDA Object.
   rda.Dispose()
End Try

[C#] 

        // Connection String to the SQL Server.
        string rdaOleDbConnectString  = "Provider=sqloledb; Data Source=MySqlServer;Initial Catalog=Northwind; " +
                                        "User Id=username;Password = <password>"; 
                                      
        // Initialize RDA Object.
        SqlCeRemoteDataAccess rda = null;

        try {
            //Try the Pull Operation.
            rda = new SqlCeRemoteDataAccess();
            
            rda.InternetLogin          = "MyLogin";
            rda.InternetPassword       = "<password>";
            rda.InternetUrl            = "<http://www.northwindtraders.com/sqlce/sscesa20.dll>";
            rda.LocalConnectionString  = @"Provider=Microsoft.SQLSERVER.OLEDB.CE.2.0;Data Source=\ssce.sdf";
           
            rda.Pull(
                "Employees", 
                "Select * from Employees", 
                rdaOleDbConnectString, 
                RdaTrackOption.TrackingOnWithIndexes , 
                "ErrorTable");
        }
        catch(SqlCeException) {
            //Use you own Error Handling Routine.
        }
        finally {
            //Dispose of the RDA Object.
            rda.Dispose();
        }

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: .NET Compact Framework

.NET Framework Security:

See Also

SqlCeRemoteDataAccess Class | SqlCeRemoteDataAccess Members | System.Data.SqlServerCe Namespace | SqlCeRemoteDataAccess.Pull Overload List

Syntax based on .NET Framework version 1.1.
Documentation version 1.1.1.

Send comments on this topic.

© Microsoft Corporation. All rights reserved.