private void monthCalendar1_DateChanged(object sender, DateRangeEventArgs e)
{
string strcon = "Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\Fellipe\\documents\\visual studio 2010\\Projects\\WindowsFormsApplication2\\WindowsFormsApplication2\\PUBS.MDF;Integrated Security=True;Connect Timeout=30;MultipleActiveResultSets=True;User Instance=True";
SqlConnection conexao = new SqlConnection(strcon);
conexao.Open();
SqlDataAdapter Buscar = new SqlDataAdapter("SELECT ROTA, DOCA FROM Planilha4 WHERE D2 =" + monthCalendar1.SelectionStart.ToString("dd/MM/yyyy"), conexao);
DataTable dt = new DataTable();
Buscar.Fill(dt);
SqlDataAdapter sda = new SqlDataAdapter();
BindingSource bSource = new BindingSource();
bSource.DataSource = dt;
dataGridView1.DataSource = bSource;
sda.Update(dt);
}
錯誤拋出在Buscar.Fill(dt);
我想消除此錯誤。我在等待答覆。 謝謝操作數類型衝突:日期與int不兼容C#
使用參數化查詢來傳遞實際日期而不是嘗試連接字符串。 –
引用您的日期以獲得簡單修復。 –