我绑定gridview与对象Datasource但它给出了错误

时间:2015-08-10 05:28:47

标签: c# asp.net .net

这里是dataaccess图层getallstudent并更新这两个用于更新并获取所有学生信息

 public void UpdateStudent(string STUDENTID, string STUDENTNAME, string STUDENTADMISSIONFEE, string STUDENTRESULT)
    {
        using (OracleConnection strConn = GetConnection())
        {
            string sql = "UPDATE STUDENTINFOS SET STUDENTNAME=@STUDENTNAME," +
                " STUDENTADMISSIONFEE=@STUDENTADMISSIONFEE,STUDENTRESULT=@STUDENTRESULT where STUDENTID=@STUDENTID";

            OracleCommand cmd = new OracleCommand(sql);

            OracleParameter paraStrId = new OracleParameter("@STUDENTID", STUDENTID);
            cmd.Parameters.Add(paraStrId);

            OracleParameter paraStrName = new OracleParameter("@STUDENTNAME", STUDENTNAME);
            cmd.Parameters.Add(paraStrName);

            OracleParameter paraStrfee = new OracleParameter("@STUDENTADMISSIONFEE", STUDENTADMISSIONFEE);
            cmd.Parameters.Add(paraStrfee);

            OracleParameter paraStrresult = new OracleParameter("@STUDENTRESULT", STUDENTRESULT);
            cmd.Parameters.Add(paraStrresult);

            cmd.Connection = strConn;
            strConn.Open();

            cmd.ExecuteNonQuery();

        }
    }

    public List<StudentDTO> GetAllStudents()
    {
        List<StudentDTO> listStudents = new List<StudentDTO>();

        using (OracleConnection strConn = GetConnection())
        {
            OracleCommand cmd = new OracleCommand("Select * from STUDENTINFOS", strConn);
            strConn.Open();
            OracleDataReader rdr = cmd.ExecuteReader();

            while (rdr.Read())
            {
                StudentDTO objStudentDTO = new StudentDTO();
                objStudentDTO.StudentId = rdr["STUDENTID"].ToString();
                objStudentDTO.StudentName = rdr["STUDENTNAME"].ToString();
                objStudentDTO.StudentAdmissionfee = rdr["STUDENTADMISSIONFEE"].ToString();
                objStudentDTO.StudentResult = rdr["STUDENTRESULT"].ToString();
                listStudents.Add(objStudentDTO);

            }

        }
        return listStudents;
    }

这是aspx页面 这些是ui gridview和objectdatasource

 <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        DataSourceID="ObjectDataSource1">
        <Columns>
            <asp:CommandField ShowEditButton="True" />
            <asp:BoundField DataField="StudentId" HeaderText="StudentId" 
                SortExpression="StudentId" />
            <asp:BoundField DataField="StudentName" HeaderText="StudentName" 
                SortExpression="StudentName" />
            <asp:BoundField DataField="StudentAdmissionfee" 
                HeaderText="StudentAdmissionfee" SortExpression="StudentAdmissionfee" />
            <asp:BoundField DataField="StudentResult" HeaderText="StudentResult" 
                SortExpression="StudentResult" />
        </Columns>
    </asp:GridView>
    <br />
    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
        SelectMethod="GetAllStudents" TypeName="SINHA.MEDLAR.STUDENT.DAL.StudentDAL" 
        UpdateMethod="UpdateEmployee">
        <UpdateParameters>
            <asp:Parameter Name="STUDENTID" Type="String" />
            <asp:Parameter Name="STUDENTNAME" Type="String" />
            <asp:Parameter Name="STUDENTADMISSIONFEE" Type="String" />
            <asp:Parameter Name="STUDENTRESULT" Type="String" />
        </UpdateParameters>
    </asp:ObjectDataSource

错误 显示错误我不知道为什么

  

ORA-00936:缺少表达

0 个答案:

没有答案