The only thing you are missing in both the snippet is the single quote
(') before and after the variable.
Below are the updated code snippets:
Snippet 1:
DateTime time = dtpfromDate.Value;
String query = "Select jobcode,companyName,vehicleno,shipmentdate,totalamount,advance,drivername,fromPlace,destination from jobmastertable where (shipmentdate='"+@shipmentdate+"')";
OleDbDataAdapter dAdapter = new OleDbDataAdapter(query,connString);
dAdapter.SelectCommand.Parameters.AddWithValue("@shipmentdate", time);
DataSet ds = new DataSet();dAdapter.Fill(ds,"tbljobmastertable");
tblpaymentview.DataSource = ds.Tables["tblpaymentview"].DefaultView;
Snippet 2:
public void showjobcodebySearchDate(DateTime fromdate, DateTime todate)
{
try
{
String query = "Select jobcode,companyName,vehicleno,shipmentdate,totalamount,advance,drivername, vehicletype from jobmastertable where shipmentdate >='" + dtpfromDate.Value.ToShortDateString() + "'";
OleDbDataAdapter dAdapter = new OleDbDataAdapter(query, connString);
DataSet ds = new DataSet();
dAdapter.Fill(ds, "tbluserdataview");
tbljobcodeview.DataSource = ds.Tables["tbluserdataview"].DefaultView;
}
catch (Exception exp)
{
MessageBox.Show("The application had met with some errors please restart the application :\n error:close MSAccess files");
}
}
Hope this answer your question