小编REZ*_*AMX的帖子

使用今天的日期作为条件,从数据库中选择数据

我有一个winform C#/ SQL项目正在进行中,其中我有一个数据表,其中数据存储有相应的时间戳,当用户注册投诉时,EG在表中存储了精确/接近足够的时间戳.它以"MMM dd yyyy hh:mm:ss"格式存储,表格列为"datetime".

我需要选择表中日期为今天的所有条目...到目前为止这是我的代码..

SqlConnection tod1 = new SqlConnection(@"Data Source=2011-GOA-RCC3\SQLEXPRESS;Initial Catalog=IOB_Comm;Integrated Security=True");
tod1.Open();
SqlCommand todc1 = new SqlCommand();
todc1.Connection = tod1;

DateTime today = DateTime.Today;
//DateTime todayl = today.AddDays();
DateTime dnext = today.AddDays(1);
label4.Text = today.ToString("MMM dd yyyy 00:00");
label5.Text = dnext.ToString("MMM dd yyyy 00:00");
label6.Text = label4.Text;
label7.Text = label5.Text;

DateTime d1 = Convert.ToDateTime(label4.Text);
DateTime d2 = Convert.ToDateTime(label5.Text);
dateTimePicker3.Value = today;
dateTimePicker4.Value = dnext;

var d3 = Convert.ToString(label4.Text);
var d4 = Convert.ToString(label5.Text);
//todc.CommandText = "Select * …
Run Code Online (Sandbox Code Playgroud)

c# sql sql-server-express winforms

1
推荐指数
1
解决办法
3323
查看次数

标签 统计

c# ×1

sql ×1

sql-server-express ×1

winforms ×1