简体   繁体   English

在C#中为GETDATE()插入查询

[英]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.. 我可以知道如何在C#中使用插入查询(数据库连接)访问GETDATE()值。

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 每次我登录页面时。代替更新,而是使用插入查询在gridview列中显示时间。如果使用更新查询,则无法获取使用日期过滤的搜索值列表

I have four columns(one primary too) in that i want to change only fourth cell Getdate(). 我有四列(也是一列),我只想更改第四个单元格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 初始化我想再次插入n相同的数据,而不是日期列

GETDATE()SQL SERVER函数,您可能直接调用它,因为查询将在服务器上执行。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM