如何从数据库回历日期列中获取数据到标签

时间:2019-07-18 07:56:31

标签: c#

C#代码:

string mycon2 = "Data Source=DESKTOP-CH5QO5B;Initial Catalog=NewDataBase;Integrated Security=True";
SqlConnection scon2 = new SqlConnection(mycon2);
string myquery2 = "select TransactionDate from InDocuments where SrNo=(select Max(SrNo) from InDocuments)";
SqlCommand cmd2 = new SqlCommand();
cmd2.CommandText = myquery2;
cmd2.Connection = scon2;
SqlDataAdapter da2 = new SqlDataAdapter();
da2.SelectCommand = cmd2;
DataSet ds2 = new DataSet();
da2.Fill(ds2);
Label3.Text = ds2.Tables[0].Rows[0]["TransactionDate"].ToString();
int x;
x = Convert.ToInt16(Label3.Text);
x = x + 0;
Label3.Text = x.ToString();
scon2.Close();

引发以下异常:

  

System.ArgumentOutOfRangeException:'不支持指定的时间   在这个日历中。它应该在04/30/1900 00:00:00之间(格里高里   日期)和11/16/2077 23:59:59(包括格里高利日期)。参数   名称:时间'

0 个答案:

没有答案