0
我想更好地瞭解如何聲明一個變量(字符串)以及方法如何工作。我試圖重新格式化日期(從calendarextender)到一個字符串,並將其作爲參數傳遞到查詢填充gridview。 (這關係到我的previous question.) 的轉換語句如下所示:變量和方法
string s_apptdate = apptDate_CalendarExtender.SelectedDate.ToString("yyyyMMdd");
如果它走在下面的方法是什麼?或者在一種方法中,它是自己的?當我把它放在下面的方法,我得到一個錯誤「沒有超載的方法‘的ToString’需要1個參數」 我的方法是這樣的
private void query1()
{
string s_apptdate = "07/15/2011";
SqlConnection conn = new SqlConnection("Data Source=*****;Initial Catalog=*****;Persist Security Info=True;User ID=sa;Password=*****");
string command = "SELECT column1, column2 FROM table where appt_date = '" + s_apptdate + "'";
SqlDataAdapter comm = new SqlDataAdapter(command, conn);
DataSet ds = new DataSet();
comm.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}
請你提供更多的信息後做
納秒。 「它是否在我的查詢..」? – dknaack
這是關於SelectedDate.ToString()方法的全部內容嗎? – Tigran
我在原有問題上貼了方法,希望這有助於澄清。我假設我會在這個方法中插入字符串語句? –