inserting time into postgres

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sambarker123
    New Member
    • Feb 2008
    • 3

    inserting time into postgres

    Hi,
    I am using c# code to connet with postgres.

    I have posted bit and pieces of the code

    NpgsqlCommand command1 = new NpgsqlCommand(" INSERT INTO test(col1,col2) VALUES (:val1,:val2)", conn1);

    // Now add the parameter to the parameter collection of the command specifying its type.

    command1.Parame ters.Add(new NpgsqlParameter ("va1", DbType.Date));
    command1.Parame ters.Add(new NpgsqlParameter ("val2", DbType.Time));


    command1.Parame ters[0].Value = CurrTime.Date;
    command1.Parame ters[1].Value = CurrTime.TimeOf Day;


    command1.Execut eNonQuery();


    When I execute the query, I am getting the error


    unexpected EOF on client connection

    could not receive data from client: No connection could be made because the target machine actively refused it.
    unexpected EOF on client connection

    If I insert only the date.The query is getting exectuted

    Cheers,
    Sam
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    You need to parse the date to proper format before passing to database.

    Comment

    • Pramod Gautam
      New Member
      • Mar 2008
      • 4

      #3
      you have to need use subquery
      use this
      insert into tableName values((select Current_time as columnName));

      Comment

      Working...