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 7833207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T12:36:08+00:00 2026-06-02T12:36:08+00:00

I want Insert Data Table in DataBase public void InsertNote(DataTable dataTable) { var query

  • 0

I want Insert Data Table in DataBase

    public void InsertNote(DataTable dataTable)
            {
                var query = new StringBuilder();

                query.Append("INSERT INTO sde.\"Table1\" 
(id, disciplol, date, second_id, note, key) VALUES ");

                foreach (DataRow row in dataTable.Rows)
                {
                    query.AppendFormat(" ({0}, '{1}', '{2}', {3}, '{4}', '{5}'),", 
row["classid"], row["disciplina"], row["datelesson"], row["student_id"], "", row["key"]);
                }

                // TODO : Review
                query.Replace(',', ';', query.Length - 2, 2);

                var cmd = new PgSqlCommand(query.ToString());

                var con = DB.Sqlconnection;
                cmd.Connection = con;
                con.Open();
                try
                {
                    cmd.ExecuteNonQuery();
                    // result = true;
                }
                catch (Exception ex)
                {
                    //result = false;
                    log.Error("InsertInTable1", ex.ToString());
                }
                finally
                {
                    con.Close();
                }
            }

In generated CMD I have this query:

INSERT INTO sde."RegistruNote" (first_id, discipline, date, second_id, note, key) VALUES  
(131415, 'Painting', '4/20/2012 12:00:00 AM', 432431, 'asd', 'aWbhxZn3X'), 
(131415, 'Painting', '4/20/2012 12:00:00 AM', 432432, 'fas', '3Dl8YCSgX'), 
(131415, 'Painting', '4/20/2012 12:00:00 AM', 432433, 'asd', '8RiBgcjuL'), 
(131415, 'Painting', '4/20/2012 12:00:00 AM', 432434, 'fds', '8rAW1VfC7'), 
(131415, 'Painting', '4/20/2012 12:00:00 AM', 432435, 'gfd', 'LhRP2y5Ji'), 
(131415, 'Painting', '4/20/2012 12:00:00 AM', 432436, 'wer', 'lGVa5boYs'), 
(131415, 'Painting', '4/20/2012 12:00:00 AM', 432437, 'wer', 'hbFfo2zNg'), 
(131415, 'Painting', '4/20/2012 12:00:00 AM', 432438, 'we', 'xEq7iAhMi'), 
(131415, 'Painting', '4/20/2012 12:00:00 AM', 432439, 'rew', 'drFNV9sCm'), 
(131415, 'Painting', '4/20/2012 12:00:00 AM', 432410, 'tw', 'dJ5XwJLQy');

In catch I have this exception:
PgSqlExcetion
date/time field value out of range: “4/20/2012 12:00:00 AM”

Where do I have to convert the date to dd.mm.yyyy format ?

  • 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-02T12:36:10+00:00Added an answer on June 2, 2026 at 12:36 pm

    Take a look at using PgSqlParameter objects rather than building up your whole query as a string – it may be the case that the server is not set up to recognise the locale that your client is using.

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

Sidebar

Related Questions

I want to insert data into a table where I don't know the next
I want to insert data into the postgresql database of OpenERP, I am able
I'm new to Java. I want to create Java Array and insert data into
i retrieve data from upc database and then want to insert the data into
I want to insert a new row into an Access database. I'm looking at
I am new to iPhone development. I want to insert certain data into my
I want to insert data to database. I have a table, named member that
I want to create a service which will insert provided data into spreadsheet fields
I'm currently using the following snippet to insert data into a table in my
I created two (or more) threads to insert data in a table in database.

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.