我有一個DataGrid表tblpaymentview,我想從數據庫 我宣佈concstring 獲取值並編寫代碼爲查詢返回什麼
private void btnsearch_Click(object sender, EventArgs e)
{
try
{
DateTime time = dtpfromDate.Value;
String query = "Select jobcode,companyName,vehicleno,shipmentdate,totalamount,advance,drivername,fromPlace,destination from jobmastertable where (shipmentdate='"+time+"')";
OleDbDataAdapter dAdapter = new OleDbDataAdapter(query, connString);
DataSet ds = new DataSet();
dAdapter.Fill(ds);
tblpaymentview.DataSource = ds.Tables["tblpaymentview"].DefaultView;
}
catch (Exception)
{
MessageBox.Show("The application had met with some errors please restart the application :\n error:closer MSAccess files");
}
}
請誰能幫助我。我也試過(Datepicker)dtpfromdate.value.toshortdateString()也
不是一個答案,但你真的應該換數據集,OleDbDataAdapter的,等在using語句 – Manatherin 2011-02-01 13:54:19