Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7969153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:11:31+00:00 2026-06-04T07:11:31+00:00

Is it possible to share database connection between datasnap server and client? I want

  • 0

Is it possible to share database connection between datasnap server and client?

I want to execute dynamic sql in client and receive results.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T07:11:32+00:00Added an answer on June 4, 2026 at 7:11 am

    I found 2 ways to execute dynamic sql in client side

    1) Using DbxConnection (dbExpress)

    // Server code
    function TServerMethods1.GetConnection: TDbxConnection;
    begin
      Result := DBConnection.DBXConnection;
    end;
    
    
    //Client code
    dbxConnection := ServerMethods.GetConnection;
    command := dbxConnection.CreateCommand;
    command.Text := 'SELECT COUNT(1) FROM clients WHERE name LIKE :name';
    param := com.CreateParameter;
    param.Name := 'name';
    param.DataType := TDBXDataTypes.WideStringType;
    param.Value.SetString('%name%');
    command.Parameters.AddParameter(param);
    reader := command.ExecuteQuery;
    reader.Next; // to Fetch row
    ShowMessage(reader.Value[0].AsString);
    

    2) Using DataSet descendant

    Server side components

    ServerMethods class must be TDSServerModule descendant

    • TConnection descendant
    • TQuery descendant
    • TDataSetProvider (set poAllowCommanedText to true)

    Client side components

    • TSqlConnection (for DataSnap connection)
    • TDsProviderConnection (for DataSnap server methods)
    • TClientDataSet (set provider)

    code to execute query

    CDS.Close; // TClientDataSet
    CDS.CommandText := 'SELECT COUNT(*) FROM clients WHERE name LIKE :name';
    CDS.Params.ParamByName('name').AsString := '%name%';
    CDS.Open;
    ShowMessage(CDS.Fields[0].AsString);
    

    Server side code:

    MainMethods.pas

    TMainMethods = class(TDSServerModule)
      PgQuery: TPgQuery;
      PgQueryProvider: TDataSetProvider;
      PgConnection: TPgConnection;
    end;
    

    MainMethods.dfm

    object MainMethods: TMainMethods
      Height = 248
      Width = 440
      object PgConnection: TPgConnection
        Left = 200
        Top = 32
        ...
      end
      object PgQuery: TPgQuery
        Connection: PgConnection
        Left = 32
        Top = 24
      end
      object PgQueryProvider: TDataSetProvider
        DataSet = PgQuery
        Options = [poAllowCommandText, poUseQuoteChar]
        Left = 120
        Top = 24
      end
    end
    

    Client side code:

    client.pas

    TVerusClient = class(TDataModule)
      dbxVerusConnection: TSQLConnection;
      dbxSqlConnectionProvider: TDSProviderConnection;
      cdsSqlDataSet: TClientDataSet;
    end;
    

    client.dfm

    object VerusClient: TVerusClient
      Height = 271
      Width = 415
      object dbxVerusConnection: TSQLConnection
        DriverName = 'DataSnap'
        LoginPrompt = False
        ...
      end
      object dbxSqlConnectionProvider: TDSProviderConnection
        ServerClassName = 'TMainMethods'
        SQLConnection = dbxVerusConnection
        Left = 176
        Top = 32
      end
      object cdsSqlDataSet: TClientDataSet
        ProviderName = 'PgQueryProvider'
        RemoteServer = dbxSqlConnectionProvider
        Left = 176
        Top = 104
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one Sqlite Database file. I want to share my sqlite database between
Is it possible to share references to C# objects between C# and C++ code
In MS SQL is it possible to share an identity seed across tables? For
I am trying to import CSV file to SQL server database, with no success.
Is it possible to have an ODBC connection and an ADO connection share the
Whenever I restore a backup of my database in SQL Server I am presented
Is it possible to share blogroll links between different Wordpress Multi Network sites? I
I am having problems with SQL Server dropping a connection after I have dropped
I'm thinking about how to represent a complex structure in a SQL Server database.
I have read in several places that it's possible to share the objects directory

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.