none
Error : "A field/property with name 'WorkOrder_Id' was not found on selected data source ..how to clear it...

    Question

  • Hi,

    I am getting an error message as "A field or property with the name 'Work Order Id' was not found on the selected data source" while i am binding the datas to grid view ....How to rectify it....


    In my sql database I am having a table named interactive_work_order_report1$ .It holds the column names
    1.WorkOrder_Id
    2.Request_ID
    3.Product_Name
    4.Assignee_Support_Grp
    5.Request_Assignee
    6.Priority
    7.Status
    8.Submit_Date


    my coding :Default.aspx.cs

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data ;
    using System.Data .SqlClient;

    namespace my_sample
    {
    public partial class _Default : System.Web.UI.Page
    {

    string table1 = "interactive_work_order_report1$";
    protected void Page_Load(object sender, EventArgs e)
    {
    if (!IsPostBack)
    {
    getdata();
    }
    }
    public void getdata()
    {
    SqlConnection con2 = new SqlConnection("Data Source=HDCH7736;Initial catalog=dcrreport;Integrated Security=True");
    con2.Open();
    DataSet ds2 = new DataSet();
    string command2 = "select * from " +table1 ;
    SqlDataAdapter da2 = new SqlDataAdapter(command2, con2);
    da.Fill(ds2, "interactive_incident_reportdec$");
    GridView3.DataSource = ds2;
    GridView3.DataBind();
    }
    }
    }



    Source code:


    <%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="my_sample._Default" %>

    <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
    </asp:Content>
    <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <h3>            </h3>

    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <asp:GridView ID="GridView3" runat="server" AutoGenerateColumns="False">
    <Columns>
    <asp:BoundField DataField="WorkOrder_Id" HeaderText="Work Order Id" />
    <asp:BoundField DataField="Request_ID" HeaderText="Request Id" />
    <asp:BoundField DataField="Assignee_Support_Grp" HeaderText="Provider Group" />
    <asp:BoundField DataField="Product_Name" HeaderText="Product Name" />
    <asp:BoundField DataField="Request_Assignee" HeaderText="Assigned To" />
    <asp:BoundField DataField="Priority" HeaderText="Priority" />
    <asp:BoundField DataField="Status" HeaderText="Status" />
    <asp:BoundField DataField="Submit_Date" HeaderText="Submit Date" />
    </Columns>
    </asp:GridView>
    </p>
    </ContentTemplate>
    </asp:UpdatePanel>

    can any one suggest the solution.....

    Thursday, January 19, 2012 8:01 AM

Answers

  • This line is wrong as it uses the wrong table name (da also doesn't exist in your code however it looks like it should be da2):

    da.Fill(ds2, "interactive_incident_reportdec$");

    It should be

    da2.Fill(ds2, table1);
    

     


    Jeff Wharton
    MSysDev (C.Sturt), MDbDsgnMgt (C.Sturt), MCT, MCPD, MCITP, MCDBA
    Blog: Mr. Wharty's Ramblings
    MC ID: Microsoft Transcript

    Please mark answered if I've answered your question and vote for it as helpful to help other user's find a solution quicker
    • Marked as answer by mathina Wednesday, January 25, 2012 6:59 AM
    Tuesday, January 24, 2012 10:43 PM

All replies

  • Hi mathina,

    It seems that the filed 'WorkOrder_Id' is not included in the table you selected. Please check the columns of the table on your command string to see if it exists.

    Stephanie Lv

    TechNet Community Support

    Tuesday, January 24, 2012 9:57 AM
  • This line is wrong as it uses the wrong table name (da also doesn't exist in your code however it looks like it should be da2):

    da.Fill(ds2, "interactive_incident_reportdec$");

    It should be

    da2.Fill(ds2, table1);
    

     


    Jeff Wharton
    MSysDev (C.Sturt), MDbDsgnMgt (C.Sturt), MCT, MCPD, MCITP, MCDBA
    Blog: Mr. Wharty's Ramblings
    MC ID: Microsoft Transcript

    Please mark answered if I've answered your question and vote for it as helpful to help other user's find a solution quicker
    • Marked as answer by mathina Wednesday, January 25, 2012 6:59 AM
    Tuesday, January 24, 2012 10:43 PM