InvalidOperationException

InvalidOperationException

本文介绍了如何解决invalidoperationexception被捕获错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! protected void btnUpdate_Click(对象发​​件人,EventArgs e) { 尝试 { string cs = ConfigurationManager.ConnectionStrings [ SSMS]的ConnectionString; SqlConnection con = new SqlConnection(cs); SqlDataAdapter da = new SqlDataAdapter(( string )ViewState [ SELECT_QUERY],con); SqlCommandBuilder builder = new SqlCommandBuilder(da); DataSet ds =(DataSet)ViewState [ DATASET]; if (ds.Tables [ 学生]。Rows.Count > 0 ) { DataRow dr = ds.Tables [ 学生]。行[ 0 ]; dr [ 名称] = txtStudentName.Text; dr [ Gender] = ddlGender.SelectedItem; dr [ TotalMarks] = txtTotalMarks.Text; dr [ Id] = txtStudentId.Text; } da.Update(ds, 学生 ); } catch (Ex Ex) { } } } 我尝试过: i我试图运行此代码然后我得到错误invalidoperationexception被捕获在此代码解决方案 protected void btnUpdate_Click(object sender, EventArgs e) { try { string cs = ConfigurationManager.ConnectionStrings["SSMS"].ConnectionString; SqlConnection con = new SqlConnection(cs); SqlDataAdapter da = new SqlDataAdapter((string)ViewState["SELECT_QUERY"],con); SqlCommandBuilder builder = new SqlCommandBuilder(da); DataSet ds=(DataSet)ViewState["DATASET"]; if (ds.Tables["Students"].Rows.Count > 0) { DataRow dr = ds.Tables["Students"].Rows[0]; dr["Name"] = txtStudentName.Text; dr["Gender"] = ddlGender.SelectedItem; dr["TotalMarks"] = txtTotalMarks.Text; dr["Id"] = txtStudentId.Text; } da.Update(ds, "Students"); } catch(Exception Ex) { } }}What I have tried:i am trying to run this code then i get error invalidoperationexception was caught in this code 解决方案 这篇关于如何解决invalidoperationexception被捕获错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-19 09:53