如何使用C#检查Sql中的日期列必需 [英] How to Check Date Column in Sql Using C# Help Required
问题描述
这是我的编码。我需要在插入数据库之前修改日期。只有一列是variyfing Date Column是我的label2.text列它不是Varfy到Sql Server日期的日期。
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings [ CONSTR] .ConnectionString);
string CheckString =SELECT COUNT(*)FROM attandence where StaffName ='+ DropDownList1 .SelectedItem.Text +AND Dutydate =+ Label2.Text +';
SqlCommand commandCheck = new SqlCommand(CheckString,conn);
conn.Open();
int Count =(int)commandCheck.ExecuteScalar();
if(Count> 0)
{
Label4.Text =已经存在;
}
else
{
This is my Coding. I need Varify date Before Insert to Database. only one column is variyfing Date Column Is my label2.text column it is not Varfy the date to Sql Server date.
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["CONSTR"].ConnectionString);
string CheckString = "SELECT COUNT(*) FROM attandence where StaffName='" + DropDownList1.SelectedItem.Text + " AND Dutydate = " + Label2.Text + "'";
SqlCommand commandCheck = new SqlCommand(CheckString, conn);
conn.Open();
int Count = (int)commandCheck.ExecuteScalar();
if (Count > 0)
{
Label4.Text = "Already exists";
}
else
{
推荐答案
这篇关于如何使用C#检查Sql中的日期列必需的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!