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

  • SEARCH
  • Home
  • 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 8945973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:23:29+00:00 2026-06-15T12:23:29+00:00

I have written a program that use one single connection with prepared statements. So

  • 0

I have written a program that use one single connection with prepared statements. So far this works but I’m moving into using pooled connections.

I’m making the assumption that prepared statements are used together with connection pooling but I can’t get me head around how it is used in practice.

I assume that rather than having the connection object stored I create a new one for every query I run(which will be pooled).

Before I used something like this:

//Single connection at startup
var conn = NpgsqlCommand(...);
...
//Prepare all commands once at start-up
var cmd = new NpgsqlCommand("INSERT...", conn);
cmd.Parameters.Add("id", NpgsqlDbType.Integer);
cmd.Prepare();
...
//Using the command multiple times later on
cmd.Parameters["id"].Value = 4312;
cmd.ExecuteNonQuery();

Now using pooled connections, how do I prepare these commands?
I guess I would need one prepared command for every connection, but I would also need some way to get the prepared command given a connection which could be anyone from the pool.

I assume the pooling also can create new connections, then I would need to prepare a new set of commands or do I create a new NpgsqlCommand, prepare it and execute it, for every call?

Some background:
My current setup is a test with a single user where only a few calls, all of them in sequence. Later on this will be a multi-user/multiple-thread service with parallel execution.

I can see how I could create my own connection pool and write my own code to prepare commands for new threads but I have an assumption that I won’t have to write this, but I might be wrong.

I’m using Npgsql(PostgreSQL) but if possible a general solution is appreciated.

  • 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-15T12:23:31+00:00Added an answer on June 15, 2026 at 12:23 pm

    According to this question the answers are that you can’t use the connection pool.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a program that uses qhttp to get a webpage. This works
I have written a java program that is actually works as a gui to
In a previous program that I have written in C I needed a single
When I run a single-threaded program that i have written on my quad core
I have a Perl program that I've written that parses SQL-like statements and creates
This is a test program that I have written for a larger project that
I have written a c# program that calls a c++ dll that echoes the
Below I have written a sample program that I have written to learn about
I have written an ActionScript client program that tries to connect to a local
Below is a small program that I have written to count the number of

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.