throw new NotImplementedException(); [英] throw new NotImplementedException();

查看:139
本文介绍了throw new NotImplementedException();的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得错误



该方法或操作未实施。







第23行:private void BindRepeaterData()

第24行:{

第25行:抛出新的NotImplementedException ();

第26行:}

第27行:







这是我的代码以下......



使用系统;

使用System.Collections.Generic;

使用System.Linq;

使用System.Web;

使用System.Web.UI;

使用System.Web.UI.WebControls;

使用System.Data;

使用System.Data.SqlClient;



命名空间WebApplication1

{

公共部分类WebForm2:System.Web.UI.Page

{

SqlConnection con = new SqlConnection(Data Source = BLUEBIRDS-LAP; Initial Catalog = Sample; Integrated Security = True);

protected void Page_Load(object sender,EventArgs e)

{

if(!IsPostBack)

{

BindRepeaterData ();

}

}



private void BindRepeaterData()

{

抛出新的NotImplementedException();

}






protected void btnSubmit_Click(object sender,EventArgs e)

{



con.Open();

SqlCommand cmd = new SqlCommand(insert into Repeter_Table(UserName,Subject,Comment,PostedDate)value(@ userName,@ subject,@ comment,@ postedDate),con);

cmd.Parameters.AddWithValue(@ userName,txtName.Text);

cmd.Parameters.AddWithValue(@ subject,txtSubject.Text);

cmd。 Parameters.AddWithValue(@ comment,txtComment.Text) ;

cmd.Parameters.AddWithValue(@ postedDate,DateTime.Now);

cmd.ExecuteNonQuery();

con.Close ();

txtName.Text = string.Empty;

txtSubject.Text = string.Empty;

txtComment.Text = string.Empty ;

BindRepeaterData();

}





protected void RepDetails_ItemCommand(对象源,RepeaterCommandEventArgs e)

{

{

con.Open();

SqlCommand cmd = new SqlCommand(select * from Repeter_Table Order By PostedDate desc,con);

DataSet ds = new DataSet();

SqlDataAdapter da = new SqlDataAdapter(cmd);

da.Fill(ds);

RepDetails.DataSource = ds;

RepDetails.DataBind();

con.Close();

}

}

}

}





感谢您的帮助..

I got Error Like

The method or operation is not implemented.



Line 23: private void BindRepeaterData()
Line 24: {
Line 25: throw new NotImplementedException();
Line 26: }
Line 27:



This is my code Below ......

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 WebApplication1
{
public partial class WebForm2 : System.Web.UI.Page
{
SqlConnection con = new SqlConnection("Data Source=BLUEBIRDS-LAP;Initial Catalog=Sample;Integrated Security=True");
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindRepeaterData();
}
}

private void BindRepeaterData()
{
throw new NotImplementedException();
}



protected void btnSubmit_Click(object sender, EventArgs e)
{

con.Open();
SqlCommand cmd = new SqlCommand("insert into Repeter_Table (UserName,Subject,Comment,PostedDate) values(@userName,@subject,@comment,@postedDate)", con);
cmd.Parameters.AddWithValue("@userName", txtName.Text);
cmd.Parameters.AddWithValue("@subject", txtSubject.Text);
cmd.Parameters.AddWithValue("@comment", txtComment.Text);
cmd.Parameters.AddWithValue("@postedDate", DateTime.Now);
cmd.ExecuteNonQuery();
con.Close();
txtName.Text = string.Empty;
txtSubject.Text = string.Empty;
txtComment.Text = string.Empty;
BindRepeaterData();
}


protected void RepDetails_ItemCommand(object source, RepeaterCommandEventArgs e)
{
{
con.Open();
SqlCommand cmd = new SqlCommand("select * from Repeter_Table Order By PostedDate desc", con);
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(ds);
RepDetails.DataSource = ds;
RepDetails.DataBind();
con.Close();
}
}
}
}


Thanks For Your Help..

推荐答案

Visual Studio添加行:

Visual studio adds the line:
throw new NotImplementedException();

当它自动为您创建一个方法时,允许您有一个标记,表明您需要做一些工作。如果你忘记了,那么当你运行你的代码时会抛出异常,这会警告你的代码可能不起作用 - 因为你没有写过它!



删除该行,并填写代码以执行该方法的功能!

When it automatically creates a method for you, allowing you to have a marker that there is some work you have to do. If you forget, then the exception is thrown when you run your code, and this serves as a warning that your code probably won't work - because you haven't written it!

Remove the line, and fill in the code to perform the function the method is there for!


这篇关于throw new NotImplementedException();的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆