Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot call method on varchar error

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);
        }
    }
}
like image 559
JTRookie86 Avatar asked Jan 11 '12 20:01

JTRookie86


1 Answers

I noticed you have '.' instead of ',' after

ROI_TRACKING.TOTAL_SAVINGS.

It should be

ROI_TRACKING.TOTAL_SAVINGS,

Hope this will help.

like image 61
Vlad Bezden Avatar answered Nov 13 '22 01:11

Vlad Bezden