SqlCeRemoteDataAccess.SubmitSql Method

Submits SQL statements for execution on a database in Microsoft SQL Server on a remote server.

Namespace: System.Data.SqlServerCe
Assembly: System.Data.SqlServerCe (in system.data.sqlserverce.dll)

Syntax

'Declaration
Public Sub SubmitSql ( _
    sqlString As String, _
    oleDBConnectionString As String _
)
'Usage
Dim instance As SqlCeRemoteDataAccess
Dim sqlString As String
Dim oleDBConnectionString As String

instance.SubmitSql(sqlString, oleDBConnectionString)
public void SubmitSql (
    string sqlString,
    string oleDBConnectionString
)
public:
void SubmitSql (
    String^ sqlString, 
    String^ oleDBConnectionString
)
public void SubmitSql (
    String sqlString, 
    String oleDBConnectionString
)
public function SubmitSql (
    sqlString : String, 
    oleDBConnectionString : String
)

Parameters

  • sqlString
    Any SQL statement that does not return rows.
  • oleDBConnectionString
    The OLE DB connection string for the remote SQL Server database.

Remarks

The InternetUrl property must contain the URL of the SQL Server Mobile Server Agent.

The InternetLogin and InternetPassword properties must be specified if the SQL Server Mobile Server Agent is configured to use Basic or Integrated Windows authentication.

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.

Example

The following example creates a SqlCeRemoteDataAccess object, sets several properties, and then calls the SubmitSql 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 SubmitSql Operation
    '
    rda = New SqlCeRemoteDataAccess()

    rda.InternetLogin = "MyLogin"
    rda.InternetPassword = "<password>"
    rda.InternetUrl = "https://www.adventure-works.com/sqlmobile/sqlcesa30.dll"
    rda.LocalConnectionString = "Data Source=MyDatabase.sdf"

    rda.SubmitSql("CREATE TABLE MyRemoteTable (colA int)", 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 SubmitSql Operation
    //
    rda = new SqlCeRemoteDataAccess();

    rda.InternetLogin = "MyLogin";
    rda.InternetPassword = "<password>";
    rda.InternetUrl = "https://www.adventure-works.com/sqlmobile/sqlcesa30.dll";
    rda.LocalConnectionString = "Data Source=MyDatabase.sdf";

    rda.SubmitSql("CREATE TABLE MyRemoteTable (colA int)", rdaOleDbConnectString);

catch (SqlCeException)
{
    // Handle errors here
    //

finally
{
    //Dispose of the RDA object
    //
    rda.Dispose();

.NET Framework Security

  • Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see .

Platforms

Windows CE, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows XP Professional x64 Edition, Windows XP SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

Version Information

.NET Compact Framework

Supported in: 2.0, 1.0

See Also

Reference

SqlCeRemoteDataAccess Class
SqlCeRemoteDataAccess Members
System.Data.SqlServerCe Namespace