我该怎么做才能满足条件

我该怎么做才能满足条件

本文介绍了我该怎么做才能满足条件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试过以下代码但不会工作



我尝试过的事情:



 使用(SqlConnection con =  new  SqlConnection(strConnString) )
{
string strQuery = SELECT * FROM LoanRates,其中DateTime.Now介于LoanAvailableFrom和LoanAvailableTo之间;
SqlCommand cmd = new SqlCommand(strQuery);
使用(SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.Connection = con;
con.Open();
sda.SelectCommand = cmd;
sda.Fill(da);
GridView1.DataSource = da;
GridView1.DataBind();

}
}
解决方案



I tried codes below but wont work

What I have tried:

using (SqlConnection con = new SqlConnection(strConnString))
{
    string strQuery = "SELECT * FROM LoanRates where DateTime.Now between LoanAvailableFrom and LoanAvailableTo";
    SqlCommand cmd = new SqlCommand(strQuery);
    using (SqlDataAdapter sda = new SqlDataAdapter())
    {
        cmd.Connection = con;
        con.Open();
        sda.SelectCommand = cmd;
        sda.Fill(da);
        GridView1.DataSource = da;
        GridView1.DataBind();

    }
}
解决方案



这篇关于我该怎么做才能满足条件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-02 14:17