如何获取特定日期之间的数据并全部填写到数据表中?

时间:2019-05-18 11:28:49

标签: c# sql

我以前从未真正使用过sql数据库,我一直在努力获取2 datetimepickers选择的日期之间的数据并将其全部放入数据表中。

private void BtnSearch_Click(object sender, EventArgs e)
        {
            String InitialDateTL =Convert.ToString(dateTimePickerIDate.Value.ToString("dd/MM/yyyy"));
            String FinalDateTL = Convert.ToString(dateTimePickerFDate.Value.ToString("dd/MM/yyyy"));
            //string SelectedCoin = comboBoxSelectCoinTL.SelectedItem.ToString();
            //string InitialTime = txtInitialTime.Text;
            //string FinalTime = txtFinalTime.Text;
            MessageBox.Show(InitialDateTL);
            MessageBox.Show(FinalDateTL);

            SqlCommand SelectSpecificDataTL = new SqlCommand("Select * from cash where Date between @InitialDate and @FinalDate", database.cash);
            database.cash.Open();

            SelectSpecificDataTL.Parameters.AddWithValue("@InitialDate", InitialDateTL);
            SelectSpecificDataTL.Parameters.AddWithValue("@FinalDate", FinalDateTL);


            SqlDataAdapter ffff = new SqlDataAdapter(SelectSpecificDataTL.ToString(), database.cash);

            //SqlDataAdapter GetSpecificData = new SqlDataAdapter();
            //GetSpecificData.SelectCommand = SelectSpecificDataTL;
            DataTable data = new DataTable();
            ffff.Fill(data);
            TransactionsLogGraph.DataSource = data;
        }

那是我到目前为止所尝试的,我知道这可能全错了,这就是为什么我需要帮助!

0 个答案:

没有答案