I am getting the "Cannot call method on varchar" error on the "adapter.Fill(dtROI)". Can you please help me out? I am trying to fill the data table with the adapter results from the sql statement.
protected void LoadData()
{
DateTime StartDate = dpStartDate.Date;
DateTime EndDate = dpEndDate.Date;
string sql = string.Empty;
using (SqlConnection conn = new SqlConnection())
{
conn.ConnectionString = ConfigurationManager.ConnectionStrings["VTC"].ConnectionString;
conn.Open();
sql = "select RESERVATION.MEETING_PURPOSE, RESERVATION.PROGRAM_AREA, RESERVATION.START_DATE, RESERVATION.END_DATE, " +
"ROI_TRACKING.ENTRY_LOCATION, ROI_TRACKING.SALARY_SAVINGS, ROI_TRACKING.TRANSPORTATION_SAVINGS, ROI_TRACKING.TOTAL_SAVINGS. " +
"ROI_TRACKING.TOTAL_DISTANCE, ROI_TRACKING.TOTAL_FUEL, ROI_TRACKING.TOTAL_GSA, ROI_TRACKING.TOTAL_AIRFARE, ROI_TRACKING.TOTAL_INSPECTOR_SALARY, " +
"ROI_TRACKING.TOTAL_MGR_SALARY, ROI_TRACKING.TOTAL_SUPERVISOR_SALARY " +
"from RESERVATION, ROI_TRACKING WHERE ROI_TRACKING.MEETING_ID = RESERVATION.MEETING_ID";
using (SqlCommand cmd = new SqlCommand(sql, conn))
{
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = cmd;
DataTable dtROI = new DataTable();
adapter.Fill(dtROI);
gridReports.DataSource = dtROI;
gridReports.DataBind();
}
if (chkDate.Checked == true)
{
FilterDataGridByDate(StartDate, EndDate);
}
}
}
I noticed you have '.' instead of ',' after
ROI_TRACKING.TOTAL_SAVINGS.
It should be
ROI_TRACKING.TOTAL_SAVINGS,
Hope this will help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With