日期文本框的文本框 在寫日期時,在文本框中兩個日期之間的Corrs的數據來自於數據網格 * 我的代碼是: *數據:在代碼中的錯誤
private void btnSubmit_Click(object sender, EventArgs e)
{
SqlConnection cs = new SqlConnection("Data Source=IRIS-CSG-174;Initial Catalog=library_system;Integrated Security=True");
cs.Open();
SqlCommand cmd = new SqlCommand("select * from dbo.lib_issue_details where book_issue_on between=" + textBox1.Text+""+"and"+ textBox2.Text +"", cs);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
DataSet ds = new DataSet();
da.Fill(ds, "lib_issue_details");
dataGridView1.DataBindings.Add(new Binding("text", ds, "lib_issue_details.book_issue_on"));
它顯示'='附近語法不正確的錯誤。 幫助我在此代碼中...在此先感謝!
感謝您的答覆,但現在它給錯誤,當我刪除 「=」:的表達在期望條件的上下文中指定的非布爾類型,在'between2011'之間。 – niketa 2011-04-26 07:47:20
您需要在和=號之間的單詞之間有空格。最好的事情是使用參數。 – 2011-04-26 08:13:02