BAP
BAP

Reputation: 27

Insert query in C# for GETDATE()

May i know how to access GETDATE() value using insert query in C# (db connection), For Singe Cell in a row..

Every time i login into the page..Instead update, i use insert query to display time in gridview column .. If i use update query i cant get list of search values filtered using date

I have four columns(one primary too) in that i want to change only fourth cell Getdate(). value using insert query its challenging i tried more cant get result

primarycol.  col1      col2       col3    Date(col4)

12345       aaa         4000.00   a121   2014-04-14 17:08:16.437
67890       bbb         3500.00   @121   2014-04-14 17:08:22.873
112233      ccc         2000.00   12345  2014-04-14 17:07:23.700
445566      ddd         6000.00   6789   2014-04-14 15:25:29.857


SqlCommand cmd = new SqlCommand(("Insert into tablename (Date) values(GETDATE())"), con);

Init i want to insert again n again same datas ,rather then Date column

Upvotes: 0

Views: 2303

Answers (1)

Hamlet Hakobyan
Hamlet Hakobyan

Reputation: 33381

GETDATE() is the SQL SERVER function and you msut call it directly because the query wll executed on the server.

SqlCommand cmd = new SqlCommand(("Insert into tablename (Date) values(GETDATE())"), con);

Upvotes: 2

Related Questions