By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,776 Members | 1,351 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,776 IT Pros & Developers. It's quick & easy.

inserting time into postgres

P: 3
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.Parameters.Add(new NpgsqlParameter("va1", DbType.Date));
command1.Parameters.Add(new NpgsqlParameter("val2", DbType.Time));


command1.Parameters[0].Value = CurrTime.Date;
command1.Parameters[1].Value = CurrTime.TimeOfDay;


command1.ExecuteNonQuery();


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
Feb 25 '08 #1
Share this Question
Share on Google+
2 Replies


debasisdas
Expert 5K+
P: 8,127
You need to parse the date to proper format before passing to database.
Feb 25 '08 #2

P: 4
you have to need use subquery
use this
insert into tableName values((select Current_time as columnName));
Mar 11 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.