当我尝试运行我的程序时出现错误:
将 varchar 数据类型转换为 datetime 数据类型导致值超出范围。
我的 select 语句有什么问题吗?
int month=0;
if (RadioButtonList1.SelectedIndex == 0)
{ month = 1; }
else if(RadioButtonList1.SelectedIndex == 1)
{ month = 2; }
else if(RadioButtonList1.SelectedIndex == 2)
{ month = 3; }
SqlCommand cmd = new SqlCommand("SELECT thDate, thType, thAmountIn, thAmountOut from [Transaction] Where thDate > dateadd(month, -" + month + ", GETDATE())", myConnection);
da = new SqlDataAdapter(cmd);
myConnection.Open();
da.Fill(ds, "[Transaction]");
myConnection.Close();
if (!IsPostBack)
{
ViewState["vs_Transaction"] = (DataTable)ds.Tables["Transaction"];
GridView1.DataSource = ds.Tables["Transaction"];
GridView1.DataBind();
下面是我的 thDate 数据库表