asp.net发布网站的时候出现, "发布遇到错误,未将对象引用设置到对象的实例。" [问题点数:20分]

Bbs1
本版专家分:0
结帖率 0%
Bbs1
本版专家分:0
Bbs6
本版专家分:8923
Blank
脉脉勋章 绑定脉脉第三方账户获取
Blank
GitHub 绑定GitHub第三方账户获取
Blank
领英 绑定领英第三方账户获取
Bbs1
本版专家分:82
Bbs2
本版专家分:398
Bbs9
本版专家分:56451
版主
Blank
黄花 2017年11月 .NET技术大版内专家分月排行榜第二
2017年10月 .NET技术大版内专家分月排行榜第二
Blank
蓝花 2019年8月 .NET技术大版内专家分月排行榜第三
2019年6月 .NET技术大版内专家分月排行榜第三
2018年8月 .NET技术大版内专家分月排行榜第三
2018年6月 .NET技术大版内专家分月排行榜第三
2018年3月 .NET技术大版内专家分月排行榜第三
2017年12月 .NET技术大版内专家分月排行榜第三
2017年9月 .NET技术大版内专家分月排行榜第三
Bbs1
本版专家分:0
Bbs1
本版专家分:0
Bbs1
本版专家分:0
Bbs1
本版专家分:0
Bbs1
本版专家分:0
asp.net出现错误 对象引用设置对象实例
新闻列表可以显示,但点击新闻是就<em>出现</em>以上<em>错误</em>rnindex.<em>asp</em>x源文件如下:rnrn rn rn rn []rn rn rn rn rn rn rn rn rn rnrn rnindex.<em>asp</em>x.cs文件如下:rnpublic partial class index : System.Web.UI.Pagernrn commonclass cc = new commonclass();rn protected void Page_Load(object sender, EventArgs e)rn rn //时政要闻rn dlsz.DataSource = cc.GetDataSet("select top 5 * from tb_news where style='时政要闻' order by id desc","tb_news");rn dlsz.DataKeyField = "id";rn rn dlsz.DataBind();rn rn rn protected void dlsz_ItemCommand(object source, DataListCommandEventArgs e)rn rn int id = Convert.ToInt32(dlsz.DataKeys[e.Item.ItemIndex]);rn Response.Redirect("shownews.<em>asp</em>x?id="+id );rn rnrnshownews.<em>asp</em>x文件rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rnshownews.<em>asp</em>x.cs文件如下:rnpublic partial class shownews : System.Web.UI.Pagernrn commonclass cc = new commonclass();rn protected void Page_Load(object sender, EventArgs e)rn rn rn rn DataSet ds = cc.GetDataSet("select * from tb_news", "tb_news");rn rn DataRow[] row = ds.Tables["tb_news"].Select("id=" + Request.QueryString["id"]);rnrn foreach (DataRow rs in row)rn rn rn this.Page.Title = rs["title"].ToString();rn this.LabTitle.Text = rs["title"].ToString();rn this.LabContent.Text = rs["content"].ToString();rnrn rn rn rnrn rn protected void btnclose_Click(object sender, EventArgs e)rn rn Response.Write(" ");rn rnrncommonclass.cs类如下:rnusing System;rnusing System.Data;rnusing System.Configuration;rnusing System.Web;rnusing System.Web.Security;rnusing System.Web.UI;rnusing System.Web.UI.WebControls;rnusing System.Web.UI.WebControls.WebParts;rnusing System.Web.UI.HtmlControls;rnusing System.Data.SqlClient;rnrn/// rn/// commonclass 的摘要说明rn/// rnpublic class commonclassrnrn public commonclass()rn rn //rn // TODO: 在此处添加构造函数逻辑rn //rn rn public SqlConnection GetConnection()rn rn string mystr = ConfigurationManager.AppSettings["ConnectionString"].ToString();rn SqlConnection myConn = new SqlConnection(mystr);rn return myConn;rnrn rn public System.Data.DataSet GetDataSet(string sqlStr, string TableName)rn rn SqlConnection myConn = GetConnection();rn myConn.Open();rn SqlDataAdapter da = new SqlDataAdapter(sqlStr,myConn);rn DataSet ds = new DataSet();rn da.Fill(ds);rn myConn.Close();rn return ds;rn rn //连接数据库,返回sqlconnection<em>对象</em>rn rnrn<em>出现</em><em>错误</em>位置:rnshownews.<em>asp</em>x.cs文件中rn DataRow[] row = ds.Tables["tb_news"].Select("id=" + Request.QueryString["id"]);rnrn搞了好几天了,也没搞好
发布 (web): 对象引用设置对象实例
.net,C#做的网站,编译的时候不出错。<em>发布</em>的时候提示一下<em>错误</em>:rnrnrn正在生成目录“/xzddy/”。/: <em>发布</em> (web): <em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。rnrn预编译完成rn------ 跳过的<em>发布</em>: 项目 E:\xzddy\, 配置: Debug .NET ------rn rn========== 生成: 0 成功或最新,1 失败,0 被跳过 ==========rn========== <em>发布</em>: 0 个成功,0 个失败,1 个跳过 ==========rnrnrn郁闷,在线等...
发布失败“对象引用设置对象实例
vs comunity 2017最新版,在我升级win10到最新版本后,<em>出现</em>了问题。(win10没有升级前没问题,我尝试过退回win10上一个版本,这个报错没有<em>出现</em>)rnrn调试没有问题,生成解决方案也没问题,<em>发布</em>的时候<em>出现</em><em>错误</em>,“<em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。”rnrn[img=https://img-bbs.csdn.net/upload/201809/23/1537714247_45902.jpg][/img]rnrntmp文件内容为以下:rnrn2018/9/23 22:33:28rnSystem.AggregateException: 发生一个或多个<em>错误</em>。 - System.Exception: 生成失败。检查输出窗口了解更多详细信息。rn --- 内部异常堆栈跟踪的结尾 ---rn 在 System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)rn 在 Microsoft.VisualStudio.Web.Publish.PublishService.VsWebProjectPublish.<>c__DisplayClass43_0.b__2()rn 在 System.Threading.Tasks.Task`1.InnerInvoke()rn 在 System.Threading.Tasks.Task.Execute()rn--- 引发异常的上一位置中堆栈跟踪的末尾 ---rn 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)rn 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)rn 在 Microsoft.VisualStudio.ApplicationCapabilities.Publish.ViewModel.ProfileSelectorViewModel.d__127.MoveNext()rn- (内部异常 #0) System.Exception: 生成失败。检查输出窗口了解更多详细信息。<---rnrn===================rn
asp.net 对象引用设置对象实例
我想问的是,.net 在捕捉null异常的时候,在catch那里,能不能catch到具体哪个代码行出问题?rnrn我现在搞一个微信平台的,他那个demo类好几十个字段,有时候新增了或者减少了,结果又读取null值了。rnrn因为这东西要放在服务器上面才能运行的,又调试不了。只能写一个txt吧参数都写进来了,一个个比较,烦不胜烦啊~
ASP.NET对象引用设置对象实例(C#)
[code=C#]rnusing System;rnusing System.Data;rnusing System.Data.OleDb;rnusing System.Configuration;rnusing System.Collections;rnusing System.Web;rnusing System.Web.Security;rnusing System.Web.UI;rnusing System.Web.UI.WebControls;rnusing System.Web.UI.WebControls.WebParts;rnusing System.Web.UI.HtmlControls;rnrnpublic partial class testing : System.Web.UI.Pagernrn int num = 0;rn static int j=0;rn static string[] answer = new string[10];rn static int[] s = new int[10];rn static Random a = new Random();rn protected void Page_Load(object sender, EventArgs e)rn rn Random a = new Random();rn string connectionString = "Provider = Microsoft.Jet.OleDb.4.0; Data Source=" + MapPath("~/Database1.mdb");rn string b = Session["item"].ToString();rn string sql = "select *from que_table";rn OleDbConnection con = new OleDbConnection(connectionString);rnrn con.Open();rn OleDbCommand cmd = new OleDbCommand(sql, con);rn OleDbDataReader dbReader = cmd.ExecuteReader();rn int count = 1;rn while (dbReader.Read()) count++;rnrnrn int i = a.Next(count);//想要取十个完全不同的随机数为什么会这么难???rn int c = 0;rn while (c < j - 1)rn rn int bc = 0;rn for (bc = 0; bc < 10; count++)rn rn string snum = s[count].ToString();rn OleDbConnection con = new OleDbConnection(connectionString);rn con.Open();rn string sql = "Select key From que_table where queNo ='"+snum+"'";//读取参考答案rnrn OleDbCommand cmd = new OleDbCommand(sql, con);rn object obj = cmd.ExecuteScalar();rn string key = Convert.ToString(obj);rn sql = "Select queScore From que_table where queNo ='"+snum+"'";//读取分值rn cmd = new OleDbCommand(sql, con);rn int score=Convert.ToInt32(cmd.ExecuteScalar());rn int y_score;rn if (answer[count].Equals(key)) y_score = score;//这句到底错哪了?实在看不出来……rn else y_score = 0;rn sql = "insert into score_table values('" + user + "','" rn + snum + "','" + answer[count] + "'," + y_score.ToString() + ")";rn cmd = new OleDbCommand(sql, con);rn cmd.ExecuteNonQuery();rn con.Close();rn rn rn[/code]
ASP.NET 对象引用设置对象实例
rnDataFile的方法:rn protected string getXMLfile()rn rn rn string filename = "~/Posts/2.xml";rn return filename;rn rn rn因为这里datafile要传一个地址栏的参数,所以我没有直接写上路径,而是在后台写方法。rnrn运行<em>出现</em><em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>,百思不得其解,求大神指点!
asp.net request 对象引用设置对象实例
hiddenfiledrun.value=request["run"];rn报<em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。的<em>错误</em>,是怎么回事,我是新手,求高手帮忙
VS2005出现 对象引用设置对象实例
当启动VS2005调试时项目<em>出现</em>以下<em>错误</em>:rn <em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>rn当点击这个<em>错误</em>时弹出一个框框:rn提示:Cannot open the file '<em>asp</em>.netcompiler' 无法打开文档,它已被重命名,删除或移动。rnrn再次启动时 VS正常进入调试 不再提示;rnrn就是这个<em>错误</em> 不定时<em>出现</em> 该如何解决此类问题??rn对于<em>错误</em>提示:如果无法点击<em>错误</em>定位到产生<em>错误</em>的地方,该如何解决这样的问题???
为什么出现对象引用设置对象实例
我在调试没有<em>出现</em><em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。rnrn可是当放到服务器时就<em>出现</em> <em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em> 的<em>错误</em>rnrn明明用new 出一个<em>实例</em>了 为什么还有<em>错误</em>?
上传文件出现对象引用设置对象实例
string filepath = this.FileUpload1.PostedFile.FileName;rn if (String.IsNullOrEmpty(filepath))rn rn this.lbMsg.Text = "请选择你要检查的文件!";rn return;rn rn<em>错误</em>源指着"string filepath = this.FileUpload1.PostedFile.FileName;"rn
自定义控件出现对象引用设置对象实例"
做了一个控件,想在页面调用时自动把cookies中的值赋到控件上的t_email这个text表单框中,但运行时就报这个错,怎么搞?rnrnprivate void Page_Load(object sender, System.EventArgs e)rn this.t_email.Text = HttpContext.Current.Request.Cookies["email"].Value.ToString();rn
对象引用设置对象实例错误
[code=C#]rnusing System;rnusing System.Collections;rnusing System.Configuration;rnusing System.Data;rnusing System.Web;rnusing System.Web.Security;rnusing System.Web.UI;rnusing System.Web.UI.HtmlControls;rnusing System.Web.UI.WebControls;rnusing System.Web.UI.WebControls.WebParts;rnpublic partial class Company : System.Web.UI.Pagernrn RGP.IBLL.Member memberBLL = new RGP.BLL.Member();rn protected RGP.Model.Member member = new RGP.Model.Member();rn RGP.Model.Device device = new RGP.Model.Device();rn RGP.IBLL.Device deviceBll = new RGP.BLL.Device();rn RGP.IBLL.DictInfo dictBLL = new RGP.BLL.DictInfo();rn RGP.IBLL.MemberVisit visitBLL = new RGP.BLL.MemberVisit();rn protected RGP.Model.MemberVisit visit = new RGP.Model.MemberVisit();rnrn protected void Page_Load(object sender, EventArgs e)rn rn if (!Page.IsPostBack)rn rn 代码省略...............rnrn rnrn visit.VisitID = Convert.ToInt32(memberBLL.get(Request.Cookies["login_MemberID"].Value));rn visit.MemberID =int.Parse(Request.QueryString["ID"]);rn visit.VisitTime = DateTime.Now;rn visit.VisitIP = RGP.Lib.StringHandle.GetIP();rn visitBLL.add(visit);rn rn rnrn[/code]rnrn报错 rnrnrn异常详细信息: System.NullReferenceException: <em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。rnrn源<em>错误</em>: rnrnrn行 46: rn行 47: rn行 48: [color=#FF0000]visit.VisitID = Convert.ToInt32(memberBLL.get(Request.Cookies["login_MemberID"].Value));[/color]rn行 49: visit.MemberID =int.Parse(Request.QueryString["ID"]);rn行 50: visit.VisitTime = DateTime.Now;rn rn
对象引用设置对象实例错误
this.lblRuleName.Text = rule.RuleName;rnrnRuleName这个值是空的,报了一个“<em>未</em>将<em>对象</em><em>设置</em><em>引用</em>到<em>对象</em>的<em>实例</em>” 我该怎么加判断呢?求大神指教!
对象引用设置对象实例错误
使用<em>asp</em>.net做一个web管理系统,后台数据库系统采用oracle 10g。早上连接数据库时,开始几次都能正常连接,后来就<em>出现</em>了异常,异常原因是:<em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>的<em>错误</em>。到网上搜索可能的原因:rn 1、ViewState <em>对象</em>为Unll。rn  2、DateSet 空。rn  3、sql语句或Datebase的原因导致DataReader空。rn  4、声明字符串变量时<em>未</em>赋空值就应用变量。rn  5、<em>未</em>用new初始化<em>对象</em>。rn  6、Session<em>对象</em>为空。 rnrnrn  1:对控件赋文本值时,值不存在 rn  2:使用Request.QueryString()时,所获取的<em>对象</em>不存在,或在值为空时<em>未</em>赋初始值rn  3:使用FindControl时,控件不存在却没有做预处理 rn  4. 重复定义造成<em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em><em>错误</em>.rnrn 觉得自己都没有犯这些<em>错误</em>,我特别奇怪的是为什么开始几次连接成功,后来就连接失败了呢?
对象引用设置对象实例错误
FormView有一按钮,我想把它<em>设置</em>为隐藏,可以总<em>出现</em><em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em><em>错误</em>?而且我有Id为NewButton的按钮rnthis.FormViewTrackInfo.ChangeMode(FormViewMode.Insert);rn this.FormViewTrackInfo.DefaultMode = FormViewMode.Insert;rn if (this.FormViewTrackInfo.CurrentMode == FormViewMode.Insert)rn rn FormView fv = new FormView(); rn [color=#FF0000] Button bt = (Button)fv.FindControl("NewButton");[/color] bt.Visible = false;rn
对象引用设置对象实例错误??
我在一自定义过程中<em>引用</em>一Form上的TextBox框rnPublic Class frmDataBasern.....rnrnPrivate sub MySub()rn textbox1.text="12"rnrnendrnendrn运行时<em>出现</em>“<em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em><em>实例</em>”<em>错误</em>rn如何解决??
对象引用设置对象实例错误?
要做一个*.bmp的图片转存到SQL数据库中,在运行时老是出错不知道为什么?rnPrivate Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Clickrn Dim Opendlg As New OpenFileDialogrn Opendlg.Filter = "(*.bmp)|*.bmp"rn Opendlg.ShowDialog()rn fs = New IO.FileStream(Opendlg.FileName.ToString(), IO.FileMode.Open, IO.FileAccess.Read)rn Label1.Text = Opendlg.FileName.ToString()rn PictureBox1.Image = Image.FromFile(Opendlg.FileName.ToString())rn End SubrnrnrnrnPrivate Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Clickrn Dim sqlcomm As New SqlClient.SqlCommandrn Dim conn As New SqlClient.SqlConnection("server=172.16.51.222;database=rs;integrated security=true;user id=sa;pwd=sa")rnrn sqlcomm.CommandText = "INSERT INTO asd (photo) VALUES (@photo)"rn sqlcomm.Connection = connrn Dim Data(fs.Length) As Bytern fs.Read(Data, 0, Int(fs.Length))rn Dim prm1 As New SqlClient.SqlParameter("@photo", SqlDbType.VarBinary, Int(fs.Length), ParameterDirection.Input, False, 0, 0, "", DataRowVersion.Current, Data)rn sqlcomm.Parameters.Add(prm1)rnrn Tryrn conn.Open()rn sqlcomm.ExecuteNonQuery()rn conn.Close()rn fs.Close()rn Catch ex As Exceptionrn MsgBox(ex.Message)rn End Tryrn End Subrn End Class
错误对象引用设置对象实例???
指向如下代码第二行:rnNewsData newData=new NewsData();rnDataRow newDRs=newData.Tables[NewsData.TABLE_NEWSINFO].NewRow();rn 这是为什么?
对象引用设置对象实例错误??
Private Sub Butenter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Butenter.Clickrnrn If txtBJDID.Text.Trim <> "" And labZT.Tag = 0 Thenrn Dim Cm As New SqlCommand '定义新的命令<em>对象</em>rn Cm.Connection = sqlConnect '绑定数据连接rnrn Cm.CommandText = "select * from detaoerp.dbo.DetaoERPBJDGL where bjdid='" & txtBJDID.Text.Trim & "'" '查询数据是否存在rnrn Tryrn sqlConnect.Open()rnrn 'MsgBox(Cm.ExecuteScalar.ToString)rnrn If Cm.ExecuteScalar.ToString <> "" Then '如果记录存在,更新记录rn Cm.CommandText = "UPDATE detaoerp.dbo.DetaoERPBJDGL" & _rn " Set bjzk=" & 1 & _rn " Where bjdid='" & txtBJDID.Text.Trim & "'"rn '测试连接字符rn 'cString = "UPDATE detaoerp.dbo.DetaoERPWLZL" & _rnrn Tryrn Cm.ExecuteNonQuery()rn labZT.Text = "已确认"rn labZT.Tag = 1rn Catchrn MsgBox(Err.Description)rn End Tryrn Elsern MsgBox("请先保存记录后,再执行此操作.", MsgBoxStyle.Information, "提醒")rn End Ifrnrn Catch ex As Exceptionrn MsgBox(ex.ToString)rn Finallyrn sqlConnect.Close()rn End Tryrn End Ifrn End Subrnrnrnrnrn出错的地方在:rnIf Cm.ExecuteScalar.ToString <> "" Then '如果记录存在,更新记录rnrn本来执行的很正常的,后来不知道怎么又报这样的<em>错误</em>了??
对象引用设置对象实例 错误求解
代码如下 rn                  myConnection.Open ();rn SqlDataAdapter Adapter1=new SqlDataAdapter("SELECT DateTime,TagName,Value FROM v_AnalogLive WHERE TagName='SysTimeMin' ",myConnString);rnrn SqlCommandBuilder thisBuilder=new SqlCommandBuilder(Adapter1);rnrn DataSet DataSet1=new DataSet();rnrn Adapter1.Fill(DataSet1," v_AnalogLive");rn DataSet1.Tables["v_AnalogLive"].Rows[1]["Value"]=30;rn Adapter1.Update(DataSet1,"v_AnalogLive");rnrn dataGrid4.SetDataBinding(DataSet1, " v_AnalogLive");rn系统老报"<em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>"的<em>错误</em>.请问下高手们是怎么回事啊.rn
对象引用设置对象实例 错误
Dim LCID As Longrn LCID = GetSystemDefaultLCID()rn Dim LOCALE_SSHORTDATE As Long = &H1F 'short date format stringrn Dim ShortDate As String = "yyyy-MM-dd"rn Call SetLocaleInfo(LCID, LOCALE_SSHORTDATE, ShortDate)rnrn最后一句报错:<em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>rnrn附:Module1.vb文件rn Public Declare Function GetSystemDefaultLCID Lib "kernel32" () As Longrn Public Declare Function SetLocaleInfo Lib "kernel32" Alias "SetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String) As Longrnrn我是想通过程序来更改系统的短日期格式。rnrn
对象引用设置对象实例错误
UI层的代码rn[code=C#]rn AdminInfo admininfo = new AdminInfo(); AdminInfo属于model层rn admininfo.username = username; username、password从文本框中获得rn admininfo.password = password;rn rn //查数据库严重用户名、密码的正确性rn if (BLL.AdminUser.CheckUserLogin(admininfo)) ------程序运行到此次跳转到BLL层CheckUserLogin() rn rn rn //登录完成后,把用户信息传到主程序rn frmMain.UserName = username;rn frmMain.PassWord = password;rnrn this.DialogResult = DialogResult.OK;rn this.Close();rn rn[/code]rnrn[code=C#]rn public static bool CheckUserLogin(AdminInfo admininfo)rn rn return dal.CheckUserLogin(admininfo); -------到这<em>出现</em><em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em><em>错误</em>rn rn[/code]rn请教大家问题出在哪了?找了半天没找打原因,是不是在UI层检验用户不该那样写?请指点
关于“对象引用设置对象实例错误
关于“<em>未</em>将<em>对象</em><em>引用</em>到<em>设置</em><em>对象</em>的<em>实例</em>”<em>错误</em>rnrn下面这段代码是参照csdn上的一篇关于将datagridview里显示自定义控件的方法写的,功能是将返回表格的第4列显示为一个combox控件。rn但是,每次执行都会提示这个<em>错误</em>,我实验从工具箱中拖出一个combox控件命名为cmb而不是使用ComboxBox cmb = new ComboxBox();的方法,这样combox就能狗正确显示了,遗憾的是位置不是正好和单元格重叠,而是在距离单元格上面。rn调试也看不出那里的问题。rn出错代码如下:rn public partial class ADD : Formrn rn private System.Windows.Forms.ComboBox cmb = new System.Windows.Forms.ComboBox();rn public string _conn = System.Configuration.ConfigurationManager.AppSettings["connstr"];rn public ADD()rn rn InitializeComponent();rn rnrn private void Serach_Click(object sender, EventArgs e)rn rn SqlConnection conn = new SqlConnection(_conn);rn SqlCommand cmd = new SqlCommand("NormalSelect",conn);rn cmd.CommandType = CommandType.StoredProcedure;rn cmd.Parameters.Add("@MC",SqlDbType.NVarChar);rn cmd.Parameters["@MC"].Value = textBox1.Text;rn SqlDataAdapter sa = new SqlDataAdapter(cmd);rn DataTable dt = new DataTable();rn sa.Fill(dt);rn this.bindingSource1.DataSource = dt;rn this.dataGridView1.DataSource = bindingSource1;rn rnrn private void dataGridView1_CurrentCellChanged(object sender, EventArgs e)rn rn tryrn rn if (this.dataGridView1.CurrentCell.ColumnIndex == 3)rn rn Rectangle rect = this.dataGridView1.GetCellDisplayRectangle(dataGridView1.CurrentCell.ColumnIndex, dataGridView1.CurrentCell.RowIndex,true);rn string cellstr = this.dataGridView1.CurrentCell.Value.ToString();rn if (cellstr == "Overdue") cmb.Text = "过期";rn else if (cellstr == "Accept") cmb.Text = "生效";rn cmb.Left = rect.Left;rn cmb.Top = rect.Top;rn cmb.Width = rect.Width;rn cmb.Height = rect.Height;rn cmb.Visible = true;rnrnrn rn elsern rn cmb.Visible = false;rn rn rn catch(Exception ex)rn rn MessageBox.Show(ex.Message);rn rn rnrn rn private void cmbinit()rn rn DataTable dataT = new DataTable();rn DataRow DataR;rn dataT.Columns.Add("flag");rn dataT.Columns.Add("display");rn DataR = dataT.NewRow();rn DataR[0] = "Overdue";rn DataR[1] = "过期";rn dataT.Rows.Add(DataR);rn DataR = dataT.NewRow();rn DataR[0] = "Accept";rn DataR[1] = "生效";rn dataT.Rows.Add(DataR);rnrn this.cmb.ValueMember = "flag";rn this.cmb.DisplayMember = "display";rn this.cmb.DataSource = dataT;rn this.cmb.DropDownStyle = ComboBoxStyle.DropDownList;rn this.cmb.Location = new System.Drawing.Point(130, 117);rnrn rnrn private void ADD_Load(object sender, EventArgs e)rn rn cmbinit();rn this.cmb.Visible = false;rn this.cmb.SelectedIndexChanged += new EventHandler(cmb_SelectedIndexChanged);rnrn rn private void cmb_SelectedIndexChanged(object sender, EventArgs e)rn rn if (((ComboBox)sender).Text == "过期")rn rn this.dataGridView1.CurrentCell.Value = "过期";rn this.dataGridView1.CurrentCell.Tag = "Overdue";rn rn elsern rn this.dataGridView1.CurrentCell.Value = "生效";rn this.dataGridView1.CurrentCell.Tag = "Accept";rn rn rnrn
对象引用设置对象实例是什么错误?
<em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。 rn说明: 执行当前 Web 请求期间,<em>出现</em><em>未</em>处理的异常。请检查堆栈跟踪信息,以了解有关该<em>错误</em>以及代码中导致<em>错误</em>的出处的详细信息。 rnrn异常详细信息: System.NullReferenceException: <em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。rnrn源<em>错误</em>: rnrnrn行 16: protected void Page_Load(object sender, EventArgs e)rn行 17: rn行 18: postid = Request["postid"].ToString();rn行 19: SqlConnection myCon = new SqlConnection();rn行 20: myCon.ConnectionString = @"Data Source=94F18D1AA4D1470;Initial Catalog=BBS;Integrated Security=True;Pooling=False";rn rnrn源文件: d:\My Documents\Visual Studio 2005\WebSites\WebSite7_BBS\Message.<em>asp</em>x.cs 行: 18 rnrn堆栈跟踪: rnrnrn[NullReferenceException: <em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。]rn Message.Page_Load(Object sender, EventArgs e) in d:\My Documents\Visual Studio 2005\WebSites\WebSite7_BBS\Message.<em>asp</em>x.cs:18rn System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +13rn System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +45rn System.Web.UI.Control.OnLoad(EventArgs e) +80rn System.Web.UI.Control.LoadRecursive() +49rn System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3745rnrn rnrnrn--------------------------------------------------------------------------------rn版本信息: Microsoft .NET Framework 版本:2.0.50727.832; ASP.NET 版本:2.0.50727.832 rnrnrn
VS2015错误对象引用设置对象实例
导入creator构建的项目就<em>出现</em>这个<em>错误</em>,网上搜了一堆方法都是改注册表。 刚找到的解决方法:打开–C:\Users\用户名\AppData\Local\Microsoft\VisualStudio\,把文件全部删了,再打开vs就恢复默认配置了,重新<em>设置</em>就ok ...
未将对象引用设置对象实例"错误">请教"对象引用设置对象实例"错误
rndataView = dataTbl1.Copy().DefaultView;rnrn运行时,程序提示这句<em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em><em>错误</em>.怎样解决,急
奇怪的错误:“对象引用设置对象实例
我建了两个项目,一个是类库(里面包含一个<em>实例</em>方法,返回一个BITMAP<em>对象</em>),一个是ASP。NET应用(<em>引用</em>前面那个类库,处理代码如下:rndim objBitmap as bitmaprndim objClass as new myclassrnobjBitmap = objClass.GetBitmap()rn这句<em>出现</em>了<em>错误</em>, 不知所云rn因为我在同一个WINFORM项目中实现同样功能的函数,也是用上面的第三句调用却能得到正确的结果不会引发异常,真的搞不懂了,望各位大侠相助,小生感激涕零
未将对象引用设置对象实例。"">MSChart错误:"对象引用设置对象实例。"
开发环境:winxp+vb.net2003rn在窗体中有一个图表控件(MSChart)\一个CheckBox控件\一个按钮rn图表为饼状图,checkbox选中显示图表控件,<em>未</em>选不显示图表控件,代码如下rn Private FrmLoad As Boolean = Falsernrn Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Clickrn Dim i As Integerrnrn Tryrn MSChart.RowCount = 1rn MSChart.RowLabelCount = 0rn MSChart.ColumnCount = 10rn MSChart.ColumnLabel = 10rn MSChart.ShowLegend = False '图例rnrn For i = 0 To 9rn MSChart.Row = 1rn MSChart.Column = i + 1rn MSChart.Data = 13 * i 'valuern MSChart.ColumnLabel = i + 1rn Nextrn For i = 1 To MSChart.Plot.SeriesCollection.Countrn MSChart.Refresh()rn With MSChart.Plot.SeriesCollection(i).DataPoints(-1).DataPointLabelrn .LineStyle = MSChart20Lib.VtChLabelLineStyle.VtChLabelLineStyleBentrn .LocationType = MSChart20Lib.VtChLabelLocationType.VtChLabelLocationTypeOutsidern .Component = 4 '1柱上显示数4显示列名(饼)rn End Withrn MSChart.Refresh()rn Nextrn Catch ex As Exceptionrn MessageBox.Show("出错")rn End Tryrnrn End Subrnrnrn Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChangedrn If FrmLoad Thenrn MSChart.ColumnCount = 0rn If CheckBox1.Checked = True Thenrn MSChart.Visible = Truern Elsern MSChart.Visible = Falsern End Ifrn End Ifrnrn End Subrnrn Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Loadrn CheckBox1.Checked = Truern FrmLoad = Truern End Subrn第一次点按钮时不出错,点一下Checkbox让控件不显示,再按一下让它显示出来,再点按钮则出错rn出错位置是: With MSChart.Plot.SeriesCollection(i).DataPoints(-1).DataPointLabelrn .LineStyle = MSChart20Lib.VtChLabelLineStyle.VtChLabelLineStyleBentrn .LocationType = MSChart20Lib.VtChLabelLocationType.VtChLabelLocationTypeOutsidern .Component = 4 '1柱上显示数4显示列名(饼)rn End Withrn这三句中的一句,不一定是哪一句,出错时当前LineStyle\LocationType\Component是一个很大的数,如917968rn不知是什么原因,请高手指教,在下感激不尽
asp.net对象引用设置对象实例
![图片说明](https://img-ask.csdn.net/upload/201611/01/1477988227_646543.png)
求助 Asp.net 对象引用设置对象实例
Message:<em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。rnException:rnSource:System.WebrnStackTrace: 在 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)rnTargetSite:Void ProcessRequestMain(Boolean, Boolean)rnrn这是跟踪到的信息。
ASP.NET SESSION 对象引用设置对象实例
[code=HTML]rn异常详细信息: System.NullReferenceException: <em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。rnrn源<em>错误</em>:rnrn行 18: rn行 19: rn行 20: if (Session["UserName"].ToString () != "")rn行 21: rn行 22: this.lblUserName.Text = Session["UserName"].ToString();rn[/code]rnrn[code=C#]using System;rnusing System.Collections;rnusing System.Configuration;rnusing System.Data;rnusing System.Linq;rnusing System.Web;rnusing System.Web.Security;rnusing System.Web.UI;rnusing System.Web.UI.HtmlControls;rnusing System.Web.UI.WebControls;rnusing System.Web.UI.WebControls.WebParts;rnusing System.Xml.Linq;rnusing System.Web.SessionState;rnrnpublic partial class userPanel : System.Web.UI.Pagernrn protected void Page_Load(object sender, EventArgs e)rn rnrn if (Session["UserName"].ToString () != "")rn rn this.lblUserName.Text = Session["UserName"].ToString();rn rn elsern rn this.lblUserName.Text = "欢迎光临";rn rn rn[/code]rnrnrn请教是怎么回事?rnrn
asp.net问题,对象引用设置对象实例
<em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。 rn说明: 执行当前 Web 请求期间,<em>出现</em><em>未</em>经处理的异常。请检查堆栈跟踪信息,以了解有关该<em>错误</em>以及代码中导致<em>错误</em>的出处的详细信息。 rnrn异常详细信息: System.NullReferenceException: <em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。rnrn源<em>错误</em>: rnrnrn行 15: rn行 16: rn行 17: public void ProcessRequest(HttpContext context)rn行 18: rn行 19: if (context.Session["是否登录"] == null)rn rnrn源文件: D:\TDDOWNLOAD\新建文件夹 (2)\<em>asp</em>.net入门第十季\图片下载\downloadPic.ashx.cs 行: 17 rnrn堆栈跟踪: rnrnrn[NullReferenceException: <em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。]rn 图片下载.downloadPic.ProcessRequest(HttpContext context) in D:\TDDOWNLOAD\新建文件夹 (2)\<em>asp</em>.net入门第十季\图片下载\downloadPic.ashx.cs:17rn System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +100rn System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75rnrn这个<em>错误</em>是什么<em>错误</em>?有没有知道的告诉一下?
asp.net(C#) 对象引用设置对象实例
网站做完了,<em>发布</em>完了,放在一个盘里,我用IIS 建虚拟目录那种方法来浏览但是打开就<em>出现</em> “<em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>” 这种<em>错误</em>。rnrn我在VS2005中没有<em>错误</em>的,为什么??rnrnrn下面是<em>错误</em>信息:rnrn说明: 执行当前 Web 请求期间,<em>出现</em><em>未</em>处理的异常。请检查堆栈跟踪信息,以了解有关该<em>错误</em>以及代码中导致<em>错误</em>的出处的详细信息。 rnrn异常详细信息: System.NullReferenceException: <em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。rnrn源<em>错误</em>: rnrn执行当前 Web 请求期间生成了<em>未</em>处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。 rnrn堆栈跟踪: rnrnrn[NullReferenceException: <em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。]rn System.Web.Hosting.ISAPIWorkerRequestInProc.GetServerVariable(String name) +1618rn System.Web.Security.WindowsAuthenticationModule.OnEnter(Object source, EventArgs eventArgs) +593rn System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +92rn System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64rnrn rn这里是数据库连接信息:rnrnweb.config中的代码:rn[code=XML]rnrnrn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn[/code]rnrnrnrnC# 数据连接代码: 我只截取了一部分代码rn [code=C#]rnusing System;rnusing System.Data;rnusing System.Configuration;rnusing System.Collections;rnusing System.Web;rnusing System.Web.Security;rnusing System.Web.UI;rnusing System.Web.UI.WebControls;rnusing System.Web.UI.WebControls.WebParts;rnusing System.Web.UI.HtmlControls;rnusing System.Data.SqlClient;rnusing System.Web.Configuration;rnusing zsxxModels;rnusing zsxxDal;rnpublic partial class index : System.Web.UI.Pagernrn DBconn st = new DBconn();rn protected void Page_Load(object sender, EventArgs e)//高职单独招生rn rnrn SqlConnection Conn = new SqlConnection(st.strConn );rnrn SqlDataAdapter Da1 = new SqlDataAdapter("Select top 6 * from NewView where Class ='高职单独招生专栏' order by id desc", Conn);rnrn DataSet Ds1 = new DataSet();rnrn Da1.Fill(Ds1, "NewView");rnrn PagedDataSource Pds = new PagedDataSource();rnrn Pds.DataSource = Ds1.Tables["NewView"].DefaultView;rnrn Pds.AllowPaging = true;rnrn Pds.PageSize = 16;rnrn Repeater1.DataSource = Pds;rnrn Repeater1.DataBind();rnrn Rep2();rnrn Rep3();rnrn Rep4();rnrnrn rn[/code]
asp.net ViewState 对象引用设置对象实例
问题描述:用户登录后,返回到请求页面。当从一个页面跳转至登录页面后,登录成功后,可返回至请求页面。但是,若直接访问登录页面,发生异常:rnLogin.<em>asp</em>x.cs页面代码:rn[code=C#]rnprotected void Page_Load(object sender, EventArgs e)rnrn  if(!Page.IsPostBack)rn rn ViewState["UrlReferrer"]=Request.UrlReferrer.ToString();rn rnrn[/code]rn<em>错误</em>截图:rnrn[img=http://hi.csdn.net/attachment/201202/9/7766120_1328753647cw6d.png][/img]
asp.net 对象引用设置对象实例
各位好。我用vb.net 编写了如下代码: rnrn Public Function dataConn(ByVal selectStr As String) As DataSet '查询字符selectstrrn Dim ConnStr As String = System.Configuration.ConfigurationSettings.AppSettings("connstr")rn Dim mydataset As New DataSetrn Dim myConn As New SqlConnection(ConnStr)rn Dim myAdp As New SqlDataAdapter(selectStr, myConn)rn myAdp.Fill(mydataset, 0)rn mydataset.AcceptChanges()rn myConn.Close()rn Return mydatasetrn End Functionrnrn但是老是提示:“<em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。”rn这个有的时候能够运行,有的时候又不能运行了,是怎么回事啊。rnrnrn<em>错误</em>在:rnrn行 7: Dim myConn As New SqlConnection(ConnStr)rn行 8: Dim myAdp As New SqlDataAdapter(selectStr, myConn)rn行 9: myAdp.Fill(mydataset, 0) '************************这里是<em>错误</em>行**********rn行 10: mydataset.AcceptChanges()rn行 11: myConn.Close()rn rn
虚拟主机出现对象引用设置对象实例
<em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。rn说明: 执行当前 Web 请求期间,<em>出现</em><em>未</em>处理的异常。请检查堆栈跟踪信息,以了解有关该<em>错误</em>以及代码中导致<em>错误</em>的出处的详细信息。rnrn异常详细信息: System.NullReferenceException: <em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。rnrn源<em>错误</em>:rnrn执行当前 Web 请求期间生成了<em>未</em>处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。rnrn堆栈跟踪:rnrnrn[NullReferenceException: <em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。]rn UI.index.NavBind() in E:\WebsiteFramework\UI\index.<em>asp</em>x.cs:130rn UI.index.Page_Load(Object sender, EventArgs e) in E:\WebsiteFramework\UI\index.<em>asp</em>x.cs:18rn System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14rn System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35rn System.Web.UI.Control.OnLoad(EventArgs e) +99rn System.Web.UI.Control.LoadRecursive() +50rn System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627rn
IIS出现对象引用设置对象实例
这是什么问题啊,我在公司传数据进数据库,然后就<em>出现</em>了这个,是什么问题呢?[img=https://img-bbs.csdn.net/upload/201704/11/1491893414_147593.png][/img]
出现对象引用设置对象实例"?">为何"出现对象引用设置对象实例"?
C#:rnrnstring username = Session["username"].ToString();rnthis.lab_welcom.Text = "欢迎光临:" + username;rnrn<em>错误</em>提示:rnrn用户代码<em>未</em>处理 System.NullReferenceExceptionrn Message="<em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。"rnrn但跟踪发现 username 不为空,此代码是写在母版页的,如不写在母版页为正常.rnrn请问是什么原因?
未将对象引用设置对象实例"???????????">出现"对象引用设置对象实例"???????????
“/MyCharu”应用程序中的服务器<em>错误</em>。rn--------------------------------------------------------------------------------rnrn<em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。 rn说明: 执行当前 Web 请求期间,<em>出现</em><em>未</em>处理的异常。请检查堆栈跟踪信息,以了解有关该<em>错误</em>以及代码中导致<em>错误</em>的出处的详细信息。 rnrn异常详细信息: System.NullReferenceException: <em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。rnrn源<em>错误</em>: rnrn执行当前 Web 请求期间生成了<em>未</em>处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。 rnrn堆栈跟踪: rnrnrn[NullReferenceException: <em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。]rn MyCharu.实验1.DataGrid1_UpdateCommand(Object source, DataGridCommandEventArgs e) +101rn System.Web.UI.WebControls.DataGrid.OnUpdateCommand(DataGridCommandEventArgs e) +109rn System.Web.UI.WebControls.DataGrid.OnBubbleEvent(Object source, EventArgs e) +507rn System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +26rn System.Web.UI.WebControls.DataGridItem.OnBubbleEvent(Object source, EventArgs e) +106rn System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +26rn System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +121rn System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +115rn System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18rn System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33rn System.Web.UI.Page.ProcessRequestMain() +1277rnrn rnrnrn--------------------------------------------------------------------------------rn版本信息: Microsoft .NET Framework 版本:1.1.4322.573; ASP.NET 版本:1.1.4322.573 rnrn源程序:rnnamespace MyCharurnrn /// rn /// 实验1 的摘要说明。rn /// rn public class 实验1 : System.Web.UI.Pagern rn protected System.Web.UI.WebControls.DataGrid DataGrid1;rn protected System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;rn protected System.Data.SqlClient.SqlCommand sqlSelectCommand1;rn protected System.Data.SqlClient.SqlCommand sqlInsertCommand1;rn protected System.Data.SqlClient.SqlCommand sqlUpdateCommand1;rn protected System.Data.SqlClient.SqlCommand sqlDeleteCommand1;rn protected System.Data.SqlClient.SqlConnection sqlConnection1;rn protected System.Data.SqlClient.SqlCommand sqlCommand1;rn protected MyCharu.aaDataSet1 aaDataSet11;rn static int k=1;rnrnprivate void DataGrid1_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)rn rn if(e.CommandName=="AddRecord")rn rn string insCmd="insert into 驾驶员情况表(驾驶证号) values('')";rn SqlCommand sqlCommand1=new SqlCommand(insCmd,sqlConnection1);rn sqlConnection1.Open();rn //sqlCommand1.CommandText=insCmd;rn sqlCommand1.ExecuteNonQuery();rn sqlConnection1.Close();rn sqlDataAdapter1.Fill(aaDataSet11);rn DataGrid1.EditItemIndex=-1;rn DataGrid1.DataBind();rn rn rnrnprivate void DataGrid1_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)rn rn string strConn="server=xw;uid=sa;pwd=sa;database=Car";rn sqlConnection1.ConnectionString=strConn;rn rn string cmd="UPDATE 驾驶员情况表 set"; rn cmd+=" 相片='"+((System.Web.UI.HtmlControls.HtmlInputFile)e.Item.Cells[0].FindControl("File1")).Value+"'";rn cmd+="where ID="+DataGrid1.DataKeys[(int)e.Item.ItemIndex].ToString();rn rn SqlCommand sqlCommand1=new SqlCommand(cmd,sqlConnection1);rn sqlConnection1.Open();rn sqlCommand1.ExecuteNonQuery();rn sqlConnection1.Close();rn sqlDataAdapter1.Fill(aaDataSet11);rn DataGrid1.EditItemIndex=-1;rn DataGrid1.DataBind();rnrnrn rnrnrn
vb.net出现对象引用设置对象实例
[img=https://img-bbs.csdn.net/upload/201706/01/1496305304_623908.png][/img]rn[img=https://img-bbs.csdn.net/upload/201706/01/1496305318_726641.png][/img]
求助!出现对象引用设置对象实例
我是新手,想学着实现c/s模式的医院的报告查询功能,写完后运行发现最终用水晶报表输出结果,有时可以,有时就会报错“<em>未</em>处理nullreferenceexception,<em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>”这样的。[img=http://img.my.csdn.net/uploads/201304/11/1365674858_8989.png][/img]rn同样的功能我事先用<em>asp</em>.net实现了,现在用winform我弄了好半天都没找出来原因,请大家帮我看看!rn[code=csharp] 这是program.csrn static void Main()rn rn Application.EnableVisualStyles();rn Application.SetCompatibleTextRenderingDefault(false);rn Form1 login = new Form1();rn login.ShowDialog();rn if (login.DialogResult == DialogResult.OK)rn rn Application.Run(new Form2());rn rn [/code]rn[code=csharp]系统登陆rnpublic partial class Form1 : Formrn rn public Form1()rn rn InitializeComponent();rn rnrn private void button1_Click(object sender, EventArgs e)rn rn if (textBox1.Text == "")rn MessageBox.Show("用户名不能为空!,");rn elsern rn if (check(textBox1.Text, textBox2.Text))rn rn this.DialogResult = DialogResult.OK;rn rn elsern MessageBox.Show("用户名密码不正确!");rn rn rn private bool check(string name, string password)rn rn SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["bsrunconnstring"].ConnectionString);rn SqlCommand comm = new SqlCommand("Select * from SS_OPERATE_USER where YHDM=@YHDM and YHKL=@YHKL", conn);rn comm.Parameters.AddWithValue("@YHDM", textBox1.Text);rn comm.Parameters.AddWithValue("@YHKL", textBox2.Text);rn conn.Open();rn SqlDataReader dr = comm.ExecuteReader();rn if (dr.HasRows)rn rn return true;rn rn dr.Close();rn return false;rn rnrn private void button2_Click(object sender, EventArgs e)rn rn this.Close();rn rn[/code]rn[code=csharp]datagridview数据列表rnpublic partial class Form2 : Formrn rn public Form2()rn rn InitializeComponent();rn rn private void button1_Click(object sender, EventArgs e)rn rn if (IsDate(maskedTextBox1.Text) && IsDate(maskedTextBox2.Text))rn rn SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["bsrunconnstring"].ConnectionString);rn SqlDataAdapter da = new SqlDataAdapter("select HIS_PATIENT_ID ,RIS_ACCNO ,RIS_PATIENT_ID ,brxm , case brxb when 1 then '男' else '女' end as 性别,RIS_REPORT_NAME,PATIENT_TYPE ,rq from ZY_BRRY,RISREPORT where (convert(varchar(64),ZYH))=HIS_PATIENT_ID and rq between '" + maskedTextBox1.Text + "' and '" + maskedTextBox2.Text + "' ", conn);rn DataTable dt = new DataTable();rn da.Fill(dt);rn if (dt.Rows.Count > 0)rn rn dataGridView1.DataSource = dt;rn rn elsern rn MessageBox.Show("查询日期内无有效数据!");rn rn rn elsern MessageBox.Show("不合法的日期!");rn for (int i = 0; i < dataGridView1.RowCount; i++)//序号rn rn this.dataGridView1.Rows[i].Cells["序号"].Value = i + 1;rn rn rnrn private void button2_Click(object sender, EventArgs e)rn rn SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["bsrunconnstring"].ConnectionString);rn SqlDataAdapter da = new SqlDataAdapter("select HIS_PATIENT_ID ,RIS_ACCNO ,RIS_PATIENT_ID ,brxm , case brxb when 1 then '男' else '女' end as 性别 ,RIS_REPORT_NAME,PATIENT_TYPE ,rq from ZY_BRRY,RISREPORT where (convert(varchar(64),ZYH))=HIS_PATIENT_ID and brxm='" + textBox1.Text + "' ", conn);rn DataTable dt = new DataTable();rn da.Fill(dt);rn if (dt.Rows.Count > 0)rn rn dataGridView1.DataSource = dt;rn rn elsern rn MessageBox.Show("查无此人!");rn rn for (int i = 0; i < dataGridView1.RowCount; i++)//序号rn rn this.dataGridView1.Rows[i].Cells["序号"].Value = i + 1;rn rn rn protected bool IsDate(Object Expression)//时间验证rn rn if (Expression != null)rn rn if (Expression is DateTime)rn rn return true;rn rn if (Expression is string)rn rn DateTime time1;rn return DateTime.TryParse((string)Expression, out time1);rn rn rn return false;rn rn//实现任意位置双击跳转至关联病人的“HIS_PATIENT_ID”查询具体的病人报告rn private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)rn rn string s = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();rn Form3 windows3 = new Form3(s);rn windows3.Show();rn rn rn[/code]rn效果这样:[img=http://img.my.csdn.net/uploads/201304/11/1365675345_1239.png][/img]rn到了水晶报表了,我是用Dataset连接的水晶报表:rn[code=csharp]rnpublic partial class Form3 : Formrn rn string value;rn public Form3(string s)rn rn value = s;rn InitializeComponent();rn rn private void Form3_Load(object sender, EventArgs e)rn rn CrystalReport1 cr = new CrystalReport1();rn SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["bsrunconnstring"].ConnectionString);rn DataSet1 ds = new DataSet1();rn SqlDataAdapter da = new SqlDataAdapter("select KSMC,BRCH,ZYHM,RIS_PATIENT_ID ,BRXM ,BRXB ,RIS_REPORT_DESCRIPTION ,RIS_REPORT_IMPRESSION ,CSNY ,RQ ,AUDITOR from ZY_BRRY,RISREPORT ,GY_KSDM where (convert(varchar(64),ZYH)) = HIS_PATIENT_ID and KSDM=BRBQ and HIS_PATIENT_ID =" + "'" + value + "'", conn);rn if (ds.Tables.Count > 0)rn rn da.Fill(ds, "DataTable1");rn rn cr.SetDataSource(ds);rn crystalReportViewer1.ReportSource = cr;rn rn [/code]
为什么出现:对象引用设置对象实例
页面是简单的grideview和嵌套的DropDownList1rnrn但执行时说这句出<em>错误</em>了,rnrn[color=#FF0000]selectname = this.GridView1.DataKeys[e.Row.RowIndex]["songtype"].ToString();[/color]rnrn部份完整代码如下,请高人指点!rnrn[code=C#]protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)rn rn if (e.Row.RowType == DataControlRowType.DataRow)rn rnrnrnrnrn DropDownList ddl_Color = (DropDownList)e.Row.FindControl("DropDownList1");rn rn string selectname ;rnrn //ColorID = this.GridView1.DataKeys[e.Row.RowIndex]["songtype"].ToString();rnrn selectname = this.GridView1.DataKeys[e.Row.RowIndex]["songtype"].ToString();rn rn ddl_Color.SelectedValue = selectname.ToString();rn rnrn rn rnrnrnrn rn rn rn rn [/code]
显示错误对象引用设置对象实例
请教一个.net2003的问题,datalist分页后,能显示第一页,点击下一页,让显示后边页面时显示<em>错误</em>:<em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。(传值有问题)rn我的思路是:rn向主页里拖放一个自定义用户控件(搜索功能)rn选择2个条件查询(dropdownlist)rn第一个是物品类型rn第二个是物品价格rn物品类型是从数据库里读的,价格是无数据库自己添加.rn在首页选择条件后,传这两个值到查询结果页面,然后datalist从数据库中,显示信息。rn帮忙的把邮箱发来帮我调试下~~~~~~谢谢拉
C#错误对象引用设置对象实例
运行过程中报错,”<em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em><em>实例</em>“,中断代码行:  v_data[0] = HexstrAddZero(Convert.ToString(Convert.ToInt32(dataGridView1[i , 3 * j ].Value), 16)); 一开始以为是补零函数HexstrAddZero的问题,去除后还是有问题 在网上查找到前人总结的问题大全: https://www....
未将对象引用设置对象实例"错误">奇怪的"对象引用设置对象实例"错误
网站已<em>发布</em>在公网上了,这个是登陆页的后台代码,我们这边每次登陆都很正常,频繁退出登陆都没问题,但是有极个别用户每次一登陆就提示:<em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>,真是相当奇怪,网上搜索过<em>出现</em>此提示的原因,然后都一一对照了没有<em>出现</em>那些<em>错误</em>,代码如下:rn rn //请高手帮忙指教一下,谢谢!rnrnrn if (!HttpContext.Current.User.Identity.IsAuthenticated)rn rn string _UserName = TextBox1.Text;rn string _UserPassword = TextBox2.Text;rn string _GotoUrl = string.Empty;rnrn if (SafeRequest.IsSafe(UserName.ToLower()) == false)rn rn MessageBox.ShowAndRedirect(this.Page, "非法操作!", "javascript:history.back()");rn rnrn if (SafeRequest.IsSafe(UserPassword.ToLower()) == false)rn rn MessageBox.ShowAndRedirect(this.Page, "非法操作!", "javascript:history.back()");rn rnrn if (string.IsNullOrEmpty(_UserName)||string.IsNullOrEmpty(_UserPassword))rn rn MessageBox.ShowAndRedirect(this.Page, "登陆账号和密码不能为空!", "javascript:history.back()");rn rn elsern rn string UserData = string.Empty;rn int userLoginCount = 0;rn _UserPassword = DEncrypt.MD5Encryptor(_UserPassword);rn TbUserService tbService = new TbUserService();rn TList tb = new TList();rn TbUserParameterBuilder pb = new TbUserParameterBuilder();rn pb.AppendEquals(TbUserColumn.UserAccount, _UserName);rn pb.AppendEquals(TbUserColumn.UserPassword, _UserPassword);rn pb.AppendEquals(TbUserColumn.UserCheckFlag, "true");rn tb = tbService.Find(pb);rn if (tb != null && tb.Count > 0)rn rn TbUser tuser=new TbUser();rn tuser = tb[0];rn userLoginCount = Convert.ToInt32(tuser.UserLoginCount) + 1;rn tuser.UserLoginCount = userLoginCount;rn tuser.UserLoginIp = string.IsNullOrEmpty(GetRealIP)?GetRealIP:"192.168.0.1";rn tuser.UserLoginTime = DateTime.Now;rn tbService.Update(tuser);rn if (Convert.ToBoolean(tuser.UserTypeFlag) == false)rn rn UserData = tuser.UserId.ToString();rn _GotoUrl = "/Maijia/Index.<em>asp</em>x";rn rn else if (Convert.ToBoolean(tuser.UserTypeFlag) == true)rn rn if (tuser.UserParentId == 0)rn rn UserData = tuser.UserId.ToString() + "|" + tuser.UserId.ToString();rn rn elsern rn UserData = tuser.UserParentId.ToString() + "|" + tuser.UserId.ToString();rn rn if (Request.Cookies["ShoppingCartsNo"] != null)rn rn HttpCookie ak47 = Request.Cookies["ShoppingCartsNo"];rn TbShoppingCartsService cartservice = new TbShoppingCartsService();rn TList cart = new TList();rn TbShoppingCartsParameterBuilder pbb = new TbShoppingCartsParameterBuilder();rn pbb.AppendEquals(TbShoppingCartsColumn.ShoppingCartsNo, ak47.Value);rn cart = cartservice.Find(pbb);rn if (cart != null && cart.Count > 0)rn rn cartservice.Delete(cart);rn rn _GotoUrl = "/Maijia2/Basic/Index.<em>asp</em>x";rn rn elsern rn Response.Redirect("/Member/Login.<em>asp</em>x");rn rn rn elsern rn MessageBox.ShowAndRedirect(this.Page, "用户类型出错,请联系管理员!", "javascript:history.back()");rn rn FormsAuthenticationTicket Ticket = new FormsAuthenticationTicket(1, _UserName, DateTime.Now, DateTime.Now.AddDays(1), false, UserData, FormsAuthentication.FormsCookiePath);rn string encTicket = FormsAuthentication.Encrypt(Ticket);rn HttpCookie ObjCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket);rn HttpContext.Current.Response.Cookies.Add(ObjCookie);rn Response.Redirect(_GotoUrl);rn rn elsern rn MessageBox.ShowAndRedirect(this.Page, "账号或密码<em>错误</em>,请先确认账号是否已激活?", "javascript:history.back()");rn rn rn
错误对象引用设置对象实例
[code=C#]public partial class show_leave : System.Web.UI.Pagernrn OleDbConnection con;rn public void bind()rn rn if (Request.QueryString["id"] == null)rn rn Response.Redirect("msg.<em>asp</em>x?type=4");rn return;rn rn string ID = Request.QueryString["id"];rn string re_SqlStr = "select count(*) from [restore] where [leave_word_id]=" + ID;rn OleDbCommand re_cmd = new OleDbCommand(re_SqlStr, con);rn OleDbDataReader re_dr = re_cmd.ExecuteReader();rn re_dr.Read();rn re_nb.Text = re_dr[0].ToString();rn string SqlStr = "select 'a'&id as nid, leave_word_name as title,leave_word_content,leave_time as Ttime,author as UserName from [leave_word] where [id]=" + ID;rn SqlStr += " Union select 'b'&id as nid, '' as title,restore_content,restore_time as Ttime,restore_user as UserName from [restore] where [leave_word_id]=" + ID;rn OleDbDataAdapter gr_da = new OleDbDataAdapter(SqlStr, con);rn DataSet gr_ds = new DataSet();rn gr_da.Fill(gr_ds);rn GridView1.DataSource = gr_ds.Tables[0];rn GridView1.DataBind();rn title_name.Text = gr_ds.Tables[0].Rows[0]["title"].ToString();rn rn protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)rn rn if (e.Row.RowType == DataControlRowType.DataRow)rn rn WebUserControl3 w3 = (WebUserControl3)e.Row.FindControl("WebUserControl3_1");rn DataTable dt = (DataTable)GridView1.DataSource;rn DataRow[] dr = dt.Select("nid='"+GridView1.DataKeys[e.Row.RowIndex].Value.ToString()+"'");rn w3.SetContent = dr[0][2].ToString();rn w3.SetTitle = dr[0]["title"].ToString();rn w3.SetTtime = dr[0]["Ttime"].ToString();rn w3.SetUserName = dr[0]["UserName"].ToString();rn w3.Setrfloor = (GridView1.PageIndex * GridView1.PageSize) + e.Row.RowIndex + "楼";rn w3.SetLID = dr[0]["nid"].ToString(); rn if (w3.Setrfloor == "0楼")rn rn w3.Setrfloor = "楼主"; rn rn w3.showTZ(); rn rn rnrn [/code]rn[code=C#]rnpublic partial class WebUserControl3 : System.Web.UI.UserControlrnrn private string UserName;rn private string Content;rn private string Ttime;rn private string Title;rn private string rfloor;rn private string LID;rn OleDbConnection con;rn public void showTZ()rn rn string str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("App_Data/db.mdb");rn con = new OleDbConnection(str);rn con.Open();rn r_content.Text = Content;rn r_time.Text = Ttime;rn TitleName.Text = Title;rn r_floor.Text = rfloor;rn string aSqlStr;rn if (LID[0] == 'a')rn rn aSqlStr = "select [leave_word_content] from [leave_word] where [id]=" + LID.Substring(1);rn jh.ImageUrl = "images/digest_1.gif";rn top.ImageUrl = "images/istop.gif";rn del.ImageUrl = "images/del.gif";rn topLink.HRef = topLink.HRef + "&id=" + LID.Substring(1);rn JHLink.HRef = JHLink.HRef + "&id=" + LID.Substring(1);rn DELink.HRef = DELink.HRef + "&id=" + LID.Substring(1);rn jh.Visible = true;rn top.Visible = true;rn jh1.Visible = true;rn top1.Visible = true;rn del.Visible = true;rn delete.Visible = true;rn rn elsern rn aSqlStr = "select [restore_content] from [restore] where [id]=" + LID.Substring(1);rn rn OleDbCommand acmd = new OleDbCommand(aSqlStr, con);rn r_content.Text = (string)acmd.ExecuteScalar();rn string user_SqlStr = "select * from [user] where [user_name] = '" + UserName + "'";rn OleDbCommand user_cmd = new OleDbCommand(user_SqlStr, con);rn OleDbDataReader user_dr = user_cmd.ExecuteReader();rn if (user_dr.Read())rn rn r_author.Text = UserName;rn if (user_dr["job"].ToString() == "1")rn rn job.Text = "管理员";rn rn elsern rn job.Text = "普通会员";rn rn time.Text = user_dr["register_time"].ToString();rn Image3.ImageUrl = user_dr["head_url"].ToString();rn user_dr.Close();rn rn user_dr.Close();rn string leave_sql = "select count(*) from [leave_word] where [author] = '" + UserName + "'";rn OleDbCommand leave_cmd = new OleDbCommand(leave_sql, con);rn num.Text = leave_cmd.ExecuteScalar().ToString();rn user_dr.Close();rn if (Session["user_name"] != null)rn rn if (LID[0] == 'a')rn rn string usersql = "select * from [leave_word] where [id]=" + LID.Substring(1);rn OleDbCommand db = new OleDbCommand(usersql, con);rn OleDbDataReader dr = db.ExecuteReader();rn if (dr.Read())rn if (dr["author"].ToString() == Session["user_name"].ToString())rn rn Buttondel.Visible = true;rn Buttonedit.Visible = true;rn rn dr.Close();rn rn elsern rn string usersql = "select * from [restore] where [id]=" + LID.Substring(1);rn OleDbCommand db = new OleDbCommand(usersql, con);rn OleDbDataReader dr = db.ExecuteReader();rn if (dr.Read())rn if (dr["restore_user"].ToString() == Session["user_name"].ToString())rn rn Buttonedit.Visible = true;rn Buttondel.Visible = true;rn rn dr.Close();rn rn string sql = "select [job] from [user] where [user_name] = '" + Session["user_name"] + "'";rn OleDbCommand sqldb = new OleDbCommand(sql, con);rn string sqlstr = sqldb.ExecuteScalar().ToString();rn if (sqlstr == "1")rn rn Buttonedit.Visible = true;rn Buttondel.Visible = true;rn rn rn con.Close();rn rnrn protected void Buttondel_Click(object sender, EventArgs e)rn rn string str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("App_Data/db.mdb");rn con = new OleDbConnection(str);rn con.Open();rn string delsql = "";rn delsql += "delete from [restore] where [id]=";rn 出错提示代码 [color=#FF0000]delsql += LID.Substring(1); [/color]rn OleDbCommand db = new OleDbCommand(delsql, con);rn db.ExecuteNonQuery();rn Response.Redirect("msg2.<em>asp</em>x?type=3");rn rnrn public string SetUserNamern rn get return UserName; rn set UserName = value; rn rnrn public string SetContentrn rn get return Content; rn set Content = value; rn rnrn public string SetTtimern rn get return Ttime; rn set Ttime = value; rn rnrn public string SetTitlern rn get return Title; rn set Title = value; rn rnrn public string Setrfloorrn rn get return rfloor; rn set rfloor = value; rn rnrn public string SetLIDrn rn get return LID; rn set LID = value; rn rnrnrn[/code]rnrn<em>错误</em>是“<em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>”rn出错是在红色那里rn代码很乱,请见谅rn主要就是LID这一部分,求教为什么方法showTZ中可以使用rn按钮事件就不行了呢。。
错误对象引用设置对象实例
部分代码: rnpublic OleDbConnection Con()rn rn OleDbConnection DbCon = new OleDbConnection();rn string strConnection = "Provider = Microsoft.Jet.OleDb.4.0;";rn strConnection += @"Data Source = "+Server.MapPath ("DB/company.mdb"); rn DbCon.ConnectionString = strConnection;rnrn return DbCon;rn rn public DataSet ReDataSet(string quyString)rn rn DataSet ds = new DataSet();rn OleDbCommand SelCom = new OleDbCommand();rn OleDbDataAdapter DBada = new OleDbDataAdapter();rn DBada.SelectCommand.Connection = Con();rn Con().Open();rn DBada.SelectCommand = SelCom;rn DBada.SelectCommand.CommandText=quyString; DBada.SelectCommand.ExecuteNonQuery();rn DBada.Fill(ds);rn return ds;rn
未将对象引用设置对象实例"的错误">有关"对象引用设置对象实例"的错误
<em>asp</em>x文件:rnrn rn rn rn rn 图审编号rn rn rn rn rn 单项工程编号rn rn rn rn 工程名称rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn fsdrn fsdrn rn rn rn rn rn rn rn rn rn rn rn rn rn rnrncs文件:rnprivate void Button1_Click(object sender, System.EventArgs e)rn rn rn ArrayList oExArgs = new ArrayList();rn ArrayList oNames = new ArrayList();rn Label oTextBox = new Label(); rn foreach( DataListItem oDataListItem in DataList1.Items)rn rn oTextBox = ((Label)oDataListItem.FindControl("tsbh")).Text;rn oExArgs.Add(oTextBox);rn DataGrid oDataGrid = (DataGrid)oDataListItem.FindControl("projectinfo");rn foreach(DataGridItem oDataGridItem in oDataGrid.Items )rn rn CheckBox oCheckBox =(CheckBox)oDataGridItem.FindControl("mycheck");rn Label oLable = (Label)oDataGridItem.FindControl("zymyColumn");rn if(oCheckBox.Checked)rn rn oNames.Add(oLable.Text);rn rn rn rnrn rn for( int i = 0;i";rn rn rnrn rn rnrn<em>出现</em>问题:rn<em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。 rn说明: 执行当前 Web 请求期间,<em>出现</em><em>未</em>处理的异常。请检查堆栈跟踪信息,以了解有关该<em>错误</em>以及代码中导致<em>错误</em>的出处的详细信息。 rnrn异常详细信息: System.NullReferenceException: <em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。rnrn源<em>错误</em>: rnrnrn行 95: foreach( DataListItem oDataListItem in DataList1.Items)rn行 96: rn行 97: oTextBox = ((Label)oDataListItem.FindControl("tsbh")).Text;rn行 98: oExArgs.Add(oTextBox);rn行 99: DataGrid oDataGrid = (DataGrid)oDataListItem.FindControl("projectinfo");rn rnrn源文件: c:\inetpub\wwwroot\webui\fpzyry\try.<em>asp</em>x.cs 行: 97 rnrn我不知到如何改,高人帮忙!!
System.NullReferenceException: 对象引用设置对象实例错误
OracleConnection oOracleConn = new OracleConnection();rn oOracleConn.ConnectionString ="Data Source=AGENTDB;User Id=agentdba;Password=icbcsg;Integrated Security=no;";rn rn string sqlstr="select distinct BRANCH_NO from gz_users_info "; rn OracleCommand cmd=new OracleCommand(sqlstr,oOracleConn);rn oOracleConn.Open(); rnrn OracleDataReader Ord=cmd.ExecuteReader();rnrn DropDownList ddl=(DropDownList)e.Item.FindControl("DropDownList1");rn ddl.DataSource=Ord;rn ddl.DataValueField="branch_no";rn ddl.DataTextField="branch_no";rn ddl.DataBind();rn Ord.Close();rn oOracleConn.Close();rn上面的代码在ddl.DataSource=Ord;处报System.NullReferenceException: <em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em><em>错误</em>,怎么来解决?rn谢谢!rn
对象引用设置对象实例错误。。。麻烦
if (FilesArray != null || FilesArray.Length != 0) rn这句<em>出现</em>了“<em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>”<em>错误</em>。。。rn不明白了~~rn调试了一下,发现在这段代码就catch了,FilesArray返回的是rn可是上面的AppPath 、sp 、ImageFolderPath 都有值啊,FilesArray这句写错了什么??rn——————————————————————————————————————————rntry rnrn AppPath = Request.PhysicalApplicationPath;rn string sp = ((HPWebSite.Entity.Customer)Session["Customer"]).SysID;rn string ImageFolderPath = AppPath + CurrentImagesFolder.Value + "\\" + sp;//AppPath + CurrentImagesFolder.Value;rn string[] FilesArray = System.IO.Directory.GetFiles(ImageFolderPath,"*.xls");rn return FilesArray;rn rncatch(Exception ex)rnrn return null;rn
对象引用设置对象实例错误?
Dim LinkList As System.Web.UI.HtmlControls.HtmlGenericControlrn LinkList = new System.Web.UI.HtmlControls.HtmlGenericControlrn LinkList = e.Item.FindControl("linklist")rn LinkList.innerHTML = "asdf" -提示我这行<em>错误</em>???rnrn我是在Repeater绑定的span
错误:对象引用设置对象实例
详细<em>错误</em>信息:rn“/”应用程序中的服务器<em>错误</em>。rn--------------------------------------------------------------------------------rnrn<em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。 rn说明: 执行当前 Web 请求期间,<em>出现</em><em>未</em>处理的异常。请检查堆栈跟踪信息,以了解有关该<em>错误</em>以及代码中导致<em>错误</em>的出处的详细信息。 rnrn异常详细信息: System.NullReferenceException: <em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。rnrn源<em>错误</em>: rnrn执行当前 Web 请求期间生成了<em>未</em>处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。 rnrn堆栈跟踪: rnrnrn[NullReferenceException: <em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。]rn sky._Default2.IB_OK_Click(Object sender, ImageClickEventArgs e) in d:\inetpub\wwwroot\sky\Model\Login\Default.<em>asp</em>x.vb:43rn System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e) +109rn System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +69rn System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18rn System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33rn System.Web.UI.Page.ProcessRequestMain() +1330rnrn --------------------------------------------------------------------------------rn版本信息: Microsoft .NET Framework 版本:1.1.4322.2032; ASP.NET 版本:1.1.4322.2032 rnrn但该程序在本地运行正常,上传到服务器就出错,请问这是什么<em>错误</em>?怎么解决?
提示错误对象引用设置对象实例
private void btnApplySetting_Click(object sender, EventArgs e)rn rn this.Cursor = Cursors.WaitCursor;rn tryrn rn object NetworkAdapter = cmbNetworkAdapter.SelectedValue;rn if (NetworkAdapter != null)rn rn this.CurrentNetworkAdapter.NetworkAdapterName = NetworkAdapter.ToString();rn this.CurrentNetworkAdapter.ProxyServerAddress = this.txtIEProxy.Text.Trim();rn NetworkHelper.ApplyNetworkSetting(this.CurrentNetworkAdapter);rn Msg.Text = "提示信息:" + "应用配置成功!";rn rn elsern rn throw new Exception("没有指定适当的网络适配器名称。");rn rn rn catch (Exception ex)rn rn MessageBox.Show("应用配置<em>错误</em>1:" + ex.Message, "IP切换器");rn rn finallyrn rn this.Cursor = Cursors.Default;rn rn rnrn提示<em>错误</em>,<em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em><em>实例</em>
dataRelation对象引用设置对象实例错误
用的是pubs的数据库,所以大家都能看明白我说什么吧:rn代码:public partial class relation : System.Web.UI.Pagernrn private string connectionstring = WebConfigurationManager.ConnectionStrings["Pubs"].ConnectionString;rn protected void Page_Load(object sender, EventArgs e)rn rn CreatList();rn rnrn private void CreatList()rn rn string sql = "SELECT au_id,au_lname,au_fname FROM Authors";rn SqlConnection myConnection = new SqlConnection(connectionstring);rn SqlCommand myCommand = new SqlCommand(sql,myConnection);rn SqlDataAdapter myAdapter = new SqlDataAdapter(myCommand);rn DataSet mySet = new DataSet();rn rn tryrn rn myConnection.Open();rn myAdapter.Fill(mySet,"Authors");rnrn myCommand.CommandText = "SELECT au_id,title_id FROM TitleAuthor";rn myAdapter.Fill(mySet,"TitleAuther");rnrn myCommand.CommandText = "SELECT title_id,title FROM Titles";rn myAdapter.Fill(mySet,"Title"); rn rn rn catch (Exception err)rn rn lblInfo.Text = err.Message;rn rn finallyrn rn myConnection.Close();rn rn DataRelation Titles_TitleAuthor = new DataRelation("Titles_TitleAuthor",mySet.Tables["Titles"].Columns["title_id"],mySet.Tables["TitleAuthor"].Columns["title_id"]);rn DataRelation Authors_TitleAuthor = new DataRelation("Authors_TitleAuthor",mySet.Tables["Authors"].Columns["au_id"],mySet.Tables["TitleAuthors"].Columns["au_id"]);rnrn mySet.Relations.Add(Titles_TitleAuthor);rn mySet.Relations.Add(Authors_TitleAuthor);rnrn foreach (DataRow rowAuthor in mySet.Tables["Authors"].Rows)rn rn lblList.Text = " " + rowAuthor["au_fname"] + " " + rowAuthor["au_lname"] + "";rn foreach (DataRow rowTitleAuthor in rowAuthor.GetChildRows(Authors_TitleAuthor))rn rn foreach (DataRow rowTitle in rowTitleAuthor.GetParentRows(Titles_TitleAuthor))rn rn lblList.Text = " " + rowTitle["title"] + " ";rn rn rn rn rn rnrn<em>错误</em>:rn DataRelation Titles_TitleAuthor = new DataRelation("Titles_TitleAuthor",mySet.Tables["Titles"].Columns["title_id"],mySet.Tables["TitleAuthor"].Columns["title_id"]);rn DataRelation Authors_TitleAuthor = new DataRelation("Authors_TitleAuthor",mySet.Tables["Authors"].Columns["au_id"],mySet.Tables["TitleAuthors"].Columns["au_id"]);rn局部变量检查,的确Titles_TitleAuthor和Authors_TitleAuthor为null,这个例子是apress beginning <em>asp</em>.net 2.0 in c#中的,所以我特意用书中代码,也是这个问题,检查数据库主键关系没有<em>错误</em>,请问问题在什么地方。rn谢谢高手们的解答,小弟感激
===“对象引用设置对象实例错误===
我写了如下句话,其实就是想获取当前行的行数值:rn protected void gvTxnInfo_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)rn rn int index = this.GridView.SelectedRow.RowIndex;rn rn然后系统就说这句话“<em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>”,rn这是什么意思,该怎么改?
未将对象引用设置对象实例"错误">"对象引用设置对象实例"错误
<em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。 rn说明: 执行当前 Web 请求期间,<em>出现</em><em>未</em>处理的异常。请检查堆栈跟踪信息,以了解有关该<em>错误</em>以及代码中导致<em>错误</em>的出处的详细信息。 rnrn异常详细信息: System.NullReferenceException: <em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。rnrn源<em>错误</em>: rnrnrn行 39: rn行 40: BasicDataLayer dp = BasicDataLayer.Instance();rn行 41: return dp.GetEmployeeDataTableQuery(null, null);rn行 42: rn行 43: rn rnrn源文件: F:\WebSolution\WebSolution\FrameLogic\Components\BaseData\Employee.cs 行: 41 rnrn堆栈跟踪: rnrnrn[NullReferenceException: <em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。]rn Anyrun.FrameLogic.Employee.GetEmployeeDataTableAll() in F:\WebSolution\WebSolution\FrameLogic\Components\BaseData\Employee.cs:41rn WebAdmin_Skin_BaseData_Employee.Page_Load(Object sender, EventArgs e) in f:\WebSolution\WebClient\WebAdmin\Skin\BaseData\Employee.<em>asp</em>x.cs:21rn System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +13rn System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +45rn System.Web.UI.Control.OnLoad(EventArgs e) +80rn System.Web.UI.Control.LoadRecursive() +49rn System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3743rnrn rn这个问题怎么解决?
System.NullReferenceException: 对象引用设置对象实例错误???
page_load事件中rnif (!Page.IsPostBack)rn rn ds = new DataSet();rn string path = Server.MapPath("AccpCash.xml");rn ds.ReadXml(path);rn foreach (DataRowView dr in ds.Tables[0].DefaultView)rn rn ddltype.Items.Add(dr["name"].ToString());rn rn ddltype.SelectedIndex = 0;rn rnrnonclick事件中rn 运行到:rn DataRow dr = ((DataRow[])ds.Tables[0].Select("name='" + ddltype.SelectedItem.Text + "'"))[0]; 就报 这个错rn
对象引用设置对象实例错误
using System;rnusing MySql.Data.MySqlClient; rnpublic partial class database : System.Web.UI.Page rnrn protected void Page_Load(object sender, EventArgs e)rn rn string myConnectionString = "Database=******;Data Source=******;User Id=root;Password=******";rn MySqlConnection myconn = new MySqlConnection(myConnectionString);rn tryrn rn myconn.Open();rn Response.Write(" ");rn rn catch (Exception ex)rn rn Response.Write(" ");rn rn rnrnrn报错:rnrn<em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。 rn说明: 执行当前 Web 请求期间,<em>出现</em><em>未</em>处理的异常。请检查堆栈跟踪信息,以了解有关该<em>错误</em>以及代码中导致<em>错误</em>的出处的详细信息。 rnrn异常详细信息: System.NullReferenceException: <em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。rnrn源<em>错误</em>: rnrnrn行 31: protected void Session_Start(Object sender, EventArgs e)rn行 32: rn行 33: SqlConnection MyConn = new SqlConnection(Application["ConnString"].ToString());rn行 34: tryrn行 35: rn rnrn源文件: d:\Web_zgyh_Myscgg\App_Code\Global.asax.cs 行: 33 rnrn新手,大家不要见笑啊rn
未将对象引用设置对象实例"错误!!!">"对象引用设置对象实例"错误!!!
在 frmFind窗体中定义了一个函数如下:rnpublic delegate void QueryDs(DataSet ds);rnpublic event QueryDs QueryEvent;rnrn public void SetQuery(DataSet ds)rnrn Thread thread1 = new Thread(new ParameterizedThreadStart(SetQueryThread));rn thread1 .IsBackground = true;rn thread1 .Start(ds);rnrnrn在另外一个类中定义了一个函数,如下:rn public FrmQuery frmFind;//查询窗体rnpublic int QueryStartID;rnpublic int QueryEndID;rnpublic void ReQueryData(DateTime dt, DataSet QueryData, int startid, int endid)rn rn rn this.QueryDS = QueryData; rnrn if (startid != -1)rn this.QueryStartID = startid;rn if (endid != -1)rn this.QueryEndID = endid;rn if (this.QueryDS != null)rn rn DataSet QueryDS = new DataSet();rnrn this.frmFind.SetQuery(this.QueryDS );rn rn rn运行到“ this.frmFind.SetQuery(this.QueryDS );的时候,提示“"<em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>"<em>错误</em>!!!
发生错误对象引用设置对象实例
protected void Page_Load(object sender, EventArgs e)rn rnrnrnrn if (!IsPostBack)rn rn yonghuming.Items.Add("请选择");rn addxiala("yonghuzhuce", "yonghuming", "kehubianhao");rn xlm.Items.Add("请选择");rn addxiala3("xianlu", "xlm", "ddd");rnrn //chem.Items.Add("请选择");rn //addxiala1("clxinxi", "chem", "zt");rn rn string sql;rnrn sql = "select * from chedd where ID=" + Request["ID"].ToString().Trim();rn rn getdata(sql);rn rn rn rnrn<em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。 rn说明: 执行当前 Web 请求期间,<em>出现</em><em>未</em>经处理的异常。请检查堆栈跟踪信息,以了解有关该<em>错误</em>以及代码中导致<em>错误</em>的出处的详细信息。 rnrn异常详细信息: System.NullReferenceException: <em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。rnrn源<em>错误</em>: rnrnrn行 29: string sql;rn行 30: rn行 31: sql = "select * from chedd where ID=" + Request["ID"].ToString().Trim();rn行 32: rn行 33: getdata(sql);rn rn堆栈跟踪: rnrnrn[NullReferenceException: <em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。]rn chedd_updt.Page_Load(Object sender, EventArgs e) in f:\陈艳莲\cldd\chedd_updt.<em>asp</em>x.cs:31rn System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14rn System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35rn System.Web.UI.Control.OnLoad(EventArgs e) +91rn System.Web.UI.Control.LoadRecursive() +74rn System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207rnrn rnrn
莫名的错误对象引用设置对象实例
在一个<em>asp</em>x页面中<em>引用</em>了一个用户控件,该用户控件中又<em>引用</em>了另一个用户控件,加载第二个用户控件时提示“<em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>”,这到底是为什么呢?rnColuCell只不过是我在用户控件中的一个表格中的一单元格,已经在页面上画好了,却要说“<em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>”,哪位来帮帮啊?rnrn……rn行 106: ColuCell.InnerHtml = "" & cName & ""rn……rn堆栈跟踪: rn[NullReferenceException: <em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。]rn zdy_PreviewColumn.Control_Load() in F:\NewPomes\zdy\PreviewColumn.ascx.vb:106rn zdy_FirstPage.Column_Load() in F:\NewPomes\zdy\FirstPage.ascx.vb:46rn zdy_FirstPage.Page_Load(Object sender, EventArgs e) in F:\NewPomes\zdy\FirstPage.ascx.vb:25rn System.Web.UI.Control.OnLoad(EventArgs e) +99rn System.Web.UI.Control.LoadRecursive() +47rn System.Web.UI.Control.LoadRecursive() +131rn System.Web.UI.Control.LoadRecursive() +131rn System.Web.UI.Control.LoadRecursive() +131rn System.Web.UI.Control.LoadRecursive() +131rn System.Web.UI.Control.LoadRecursive() +131rn System.Web.UI.Control.LoadRecursive() +131rn System.Web.UI.Control.LoadRecursive() +131rn System.Web.UI.Control.LoadRecursive() +131rn System.Web.UI.Control.LoadRecursive() +131rn System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061rnrn rn
对象引用设置对象实例错误
代码如下:using System;rnusing System.Collections;rnusing System.Configuration;rnusing System.Data;rnusing System.Linq;rnusing System.Web;rnusing System.Web.Security;rnusing System.Web.UI;rnusing System.Web.UI.HtmlControls;rnusing System.Web.UI.WebControls;rnusing System.Web.UI.WebControls.WebParts;rnusing System.Xml.Linq;rnusing Socut.Data;rnrnnamespace WebApplication1.Newsrnrn public partial class list : System.Web.UI.Pagern rn public CData myData = new CData();rn public DataSet ds = new DataSet();rn protected void Page_Load(object sender, EventArgs e)rn rn rn ds = myData.GetDataSet("Select * from socut_news", 0, 0, "TableName");rn GridView1.DataSource = ds;rn GridView1.DataBind();rn rn rnrnrn是在这行出的<em>错误</em>:ds = myData.GetDataSet("Select * from socut_news", 0, 0, "TableName");rn刚用<em>asp</em>请指教啊!rn
未将对象引用设置对象实例】">错误【Message="对象引用设置对象实例
按照petshop模式建了一个项目,添加数据的时候报错:rnrn用户代码<em>未</em>处理 System.NullReferenceExceptionrn Message="<em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。"rn Source="BLL"rn StackTrace:rn 在 AVNVA.BLL.UserInfo.Insert(MUserInfo userinfo) 位置 E:\我的工作\AVNVA项目\ASP.NET\AVNVA\BLL\UserInfo.cs:行号 23rn 在 NewUser.Button1_Click(Object sender, EventArgs e) 位置 e:\我的工作\AVNVA项目\ASP.NET\AVNVA\Web\NewUser.<em>asp</em>x.cs:行号 97rn 在 System.Web.UI.WebControls.Button.OnClick(EventArgs e)rn 在 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)rn 在 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)rn 在 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)rn 在 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)rn 在 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)rnrnrn public void Insert(MUserInfo userinfo)rn rn 出错位置: dal.Insert(userinfo);rn rnrnrnrn
错误求助:对象引用设置对象实例
MasterPage.master的代码如下:rnrnusing System;rnusing System.Data;rnusing System.Configuration;rnusing System.Collections;rnusing System.Web;rnusing System.Web.Security;rnusing System.Web.UI;rnusing System.Web.UI.WebControls;rnusing System.Web.UI.WebControls.WebParts;rnusing System.Web.UI.HtmlControls;rnrnpublic partial class MasterPage : System.Web.UI.MasterPage rnrn rn rn protected void Page_Load(object sender, EventArgs e)rn rn if (!IsPostBack)rnrn rn this.NicknameLabel.Text = Session["username"].ToString();rn rn rn protected void logout(object sender, EventArgs e)rn rn Session.Clear();rn Response.Redirect("~/login.<em>asp</em>x");rn rnrnrn----------------rn调试时报错:rn<em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。 rn说明: 执行当前 Web 请求期间,<em>出现</em><em>未</em>处理的异常。请检查堆栈跟踪信息,以了解有关该<em>错误</em>以及代码中导致<em>错误</em>的出处的详细信息。 rnrn异常详细信息: System.NullReferenceException: <em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。rnrn源<em>错误</em>: rnrnrn行 16: protected void Page_Load(object sender, EventArgs e)rn行 17: rn行 18: if (!IsPostBack) rn行 19: this.NicknameLabel.Text = Session["username"].ToString(); rn行 20: rnrn源文件: d:\maqh\dianziweb\MasterPage.master.cs 行: 19 rnrnrn请教高手给看下,是哪里的问题啊?谢谢~!rnrnrnrn
关于“对象引用设置对象实例”的错误
上传一个文件rnrn提交后到下一个页面接收上传rnrnprivate void Page_Load(object sender, System.EventArgs e)rnrn if (Request.Files.Count > 0)rn rn string sXMLPath = Server.MapPath("./") + "upload.xml" ;rn System.Xml.XmlDocument oXMLDoc = new System.Xml.XmlDocument() ;rn oXMLDoc.Load(sXMLPath) ;rn System.Xml.XmlNode oNode = oXMLDoc.SelectSingleNode("/FCKeditor_Upload/FileNameCounter") ;rnrn int iCounter = int.Parse( oNode.InnerText ) + 1 ;rnrn oNode.InnerText = iCounter.ToString() ;rnrn oXMLDoc.Save(sXMLPath) ;rnrn oNode = null ;rn oXMLDoc = null ;rnrn System.Web.HttpPostedFile oFile = Request.Files.Get("FCKeditor_File") ;rn Label1.Text = oFile.FileName; 总是提示这行“<em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>”rn //string sFileURL = "/UserImages/" + iCounter.ToString().PadLeft(8,'0') + System.IO.Path.GetExtension(oFile.FileName) ;rn //string sFilePath = Server.MapPath(sFileURL) ;rn //oFile.SaveAs(sFilePath) ;rn rn //Response.Write("
对象引用设置对象实例
起因:文件中的类都不能进行设计,因此<em>未</em>能为该文件显示设计器。设计器检查出文件中有以下类: FormMain --- <em>未</em>能加载基类“WinForm.Win.FormsBase.FormMainBase”。请确保已<em>引用</em>该程序集并已生成所有项目我用了一个小时找百度。这个的解决方法,就是将你删除过的一个窗体,再添加上就好了。。。。有点生气的。。然后<em>出现</em>了:<em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>的问题这个问题的解决方...
对象引用设置对象实例
我在一个页面定义一个DataTable表 里面已经有数据,把他传到用户控件的后天代码?我是这样写的,为什么老是报出<em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。难道穿过来的表是空的吗?[img=https://img-bbs.csdn.net/upload/201404/23/1398214107_854588.jpg][/img][img=https://img-bbs.csdn.net/upload/201404/23/1398214118_325346.jpg][/img][img=https://img-bbs.csdn.net/upload/201404/23/1398214129_620204.jpg][/img]
对象引用设置对象实例???
private void 音乐试听ToolStripMenuItem_Click(object sender, EventArgs e)rn rn Frm_YinYue x = new Frm_YinYue();rn x.ShowDialog();//就是这里<em>出现</em>问题的rn rn rn 下面的这是Frm_YinYuernrn public partial class Frm_YinYue : Formrn rn //申明一个字符串数组来储存歌曲的地址rn private string[] urlname = new string[2000];rn WMPLib.IWMPMediaCollection mediacollection;rn WMPLib.IWMPMedia media;rnrn //添加单个地址上的mp3文件rnrn private void Addfile(string path)rn rn string songname = path.Substring(path.LastIndexOf('\\') + 1);rn songname = songname.Substring(0, songname.Length - 4);rn mediacollection = axWindowsMediaPlayer1.mediaCollection;rn media = mediacollection.add(path);rn axWindowsMediaPlayer1.currentPlaylist.appendItem(media);rn mediacollection.remove(media, false);rn listBox1.Items.Add(songname);rn urlname[listBox1.Items.Count - 1] = path;rn rnrn public Frm_YinYue()rn rn InitializeComponent();rn rnrn private void 打开文件ToolStripMenuItem_Click(object sender, EventArgs e)rn rn tryrn rn DialogResult result = openFileDialog1.ShowDialog();rn if (result == DialogResult.OK)rn rnrn //songname为歌曲名rn string songname = openFileDialog1.FileName.Substring(openFileDialog1.FileName.LastIndexOf("\\") + 1);rn songname = songname.Substring(0, songname.Length - 1);rn //刷新当前播放的列表rn axWindowsMediaPlayer1.currentPlaylist.clear();rn //同步刷新listBoxrn listBox1.Items.Clear();rn axWindowsMediaPlayer1.URL = openFileDialog1.FileName;rn this.Text = songname + "--Windows Media Player";rn listBox1.Items.Add(songname);rn urlname[listBox1.Items.Count - 1] = openFileDialog1.FileName;rn //播放当前打开的曲目rn axWindowsMediaPlayer1.Ctlcontrols.play();rnrn rnrn rn catch (Exception error)rn rn MessageBox.Show(error.Message.ToString());rn rn rnrn private void 删除文件ToolStripMenuItem_Click(object sender, EventArgs e)rn rn //listBox1.Items.Clear();//这里的是清除listbox中的所有内容rn listBox1.Items.Remove(listBox1.SelectedItem.ToString ());//此处是删除listbox中选中的项rn // this.axWindowsMediaPlayer1.Ctlcontrols.stop();//停止播放rn rn rnrn private void 关闭ToolStripMenuItem_Click(object sender, EventArgs e)rn rn listBox1.Items.Clear();rn rnrn private void 添加单个文件ToolStripMenuItem_Click(object sender, EventArgs e)rn rn tryrn rn DialogResult result = openFileDialog1.ShowDialog();rn if (result == DialogResult.OK)rn rn this.Addfile(openFileDialog1.FileName);rn urlname[listBox1.Items.Count - 1] = openFileDialog1.FileName;rn //播放当前打开的曲目rn axWindowsMediaPlayer1.Ctlcontrols.play();rnrn rn rn catch (Exception error)rn rn MessageBox.Show(error.Message.ToString());rn rn rn private void 播放rlToolStripMenuItem_Click(object sender, EventArgs e)rn rn if (listBox1.Items.Count > 0)rn rn if (this.listBox1.SelectedItems.Count > 0)rn rn if (axWindowsMediaPlayer1.playState == WMPLib.WMPPlayState.wmppsPaused)rn rn axWindowsMediaPlayer1.Ctlcontrols.play();rn rn elsern axWindowsMediaPlayer1.Ctlcontrols.pause();rnrn rn rn elsern rn MessageBox.Show("请选择歌曲!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);rn rn rnrn private void 上一曲ToolStripMenuItem_Click(object sender, EventArgs e)rn rn tryrn rn if (listBox1.SelectedIndex >= 0)rn listBox1.SelectedIndex = listBox1.SelectedIndex - 1;rn if (listBox1.SelectedIndex < 0)rn rn listBox1.SelectedIndex = listBox1.Items.Count - 1;rn rnrn //这里的代码是:当选择了上一曲后,就立即播放上一曲rnrn WMPLib.IWMPMedia nowmedia = axWindowsMediaPlayer1.currentPlaylist.get_Item(listBox1.SelectedIndex);rn axWindowsMediaPlayer1.Ctlcontrols.playItem(nowmedia);rnrn rn catch (Exception) ;rn rnrn private void 下一曲ToolStripMenuItem_Click(object sender, EventArgs e)rn rn axWindowsMediaPlayer1.Ctlcontrols.next();//这个是系统自带的下一曲方法rnrn tryrn rn if (listBox1.SelectedIndex >= 0)rn listBox1.SelectedIndex = listBox1.SelectedIndex +1;rn if (listBox1.SelectedIndex < 0)rn rn listBox1.SelectedIndex = listBox1.Items.Count +1;rn rnrn //这里的代码是:当选择了上一曲后,就立即播放上一曲rn WMPLib.IWMPMedia nowmedia = axWindowsMediaPlayer1.currentPlaylist.get_Item(listBox1.SelectedIndex);rn axWindowsMediaPlayer1.Ctlcontrols.playItem(nowmedia);rnrn rn catch (Exception) ;rn rnrn rnrn rnrn private void listBox1_DoubleClick(object sender, EventArgs e)rn rn if (listBox1.SelectedIndex > -1)rn rn WMPLib.IWMPMedia nowmedia = axWindowsMediaPlayer1.currentPlaylist.get_Item(listBox1.SelectedIndex);rn axWindowsMediaPlayer1.Ctlcontrols.playItem(nowmedia);rnrn rn rnrn rnrn private void 打开文件ToolStripMenuItem2_Click(object sender, EventArgs e)rn rn 打开文件ToolStripMenuItem_Click(sender, e);rn rnrn private void 上一曲ToolStripMenuItem1_Click(object sender, EventArgs e)rn rn 上一曲ToolStripMenuItem_Click(sender, e);rn rnrn private void 下一曲ToolStripMenuItem1_Click(object sender, EventArgs e)rn rn 下一曲ToolStripMenuItem_Click(sender, e);rn rnrn private void 停止ToolStripMenuItem_Click(object sender, EventArgs e)rn rn axWindowsMediaPlayer1.Ctlcontrols.stop();rn rnrn private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)rn rn DialogResult dr = MessageBox.Show("您确定要退出吗?", "系统提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information);rn if (dr == DialogResult.Yes)rn this.Close();rn elsern return;rn rnrn private void toolStripMenuItem3_Click(object sender, EventArgs e)rn rn 添加单个文件ToolStripMenuItem_Click(sender, e);rn rnrn private void toolStripMenuItem2_Click(object sender, EventArgs e)rn rn listBox1.Items.Remove(listBox1.SelectedItem.ToString());rn rn rn
对象引用设置对象实例??
<em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。 rn说明: 执行当前 Web 请求期间,<em>出现</em><em>未</em>处理的异常。请检查堆栈跟踪信息,以了解有关该<em>错误</em>以及代码中导致<em>错误</em>的出处的详细信息。 rnrn异常详细信息: System.NullReferenceException: <em>未</em>将<em>对象</em><em>引用</em><em>设置</em>到<em>对象</em>的<em>实例</em>。rnrn源<em>错误</em>: rnrnrn行 24: using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["CarManage"].ConnectionString))rn行 25: rn行 26: using (SqlCommand command = new SqlCommand("insert into UserMessage(UserName,UPassword,UCode,UName,USex,UBir,UMZ,USFZ,UPhone,UBuMen,UAddress,UPerMissions) values('" + this.TextBox1.Text + "','" + this.TextBox2.Text + "','" + this.TextBox4.Text + "','" + this.TextBox9.Text + "'," + this.RadioButtonList1.SelectedValue + ",'" + birthday.Value + "','" + DropDownListNation.Items[this.DropDownListNation.SelectedIndex].Text + "','" + this.TextBox5.Text + "','" + this.TextBox6.Text + "','" + this.bumen.Items[this.DropDownListNation.SelectedIndex].Text + "','" + this.TextBox7.Text + "','" + RadioButtonList2.SelectedItem.Text + "')"))rn行 27: rn行 28: connection.Open();//打开数据库连接rn rnrn源文件: f:\CarManage\Register.<em>asp</em>x.cs 行: 26 rnrn//源文件rnpublic partial class Register : System.Web.UI.Pagernrn protected void Page_Load(object sender, EventArgs e)rn rnrn rn protected void Button1_Click(object sender, EventArgs e)rn rn using (SqlConnection connection = new SqlConnectionrnrn(ConfigurationManager.ConnectionStrings["CarManage"].ConnectionString))rn rn using (SqlCommand command = new SqlCommand("insert into UserMessagernrn(UserName,UPassword,UCode,UName,USex,UBir,UMZ,USFZ,UPhone,UBuMen,UAddress,UPerMissiornrnns) values('" + this.TextBox1.Text + "','" + this.TextBox2.Text + "','" + rnrnthis.TextBox4.Text + "','" + this.TextBox9.Text + "'," + rnrnthis.RadioButtonList1.SelectedValue + ",'" + birthday.Value + "','" + rnrnDropDownListNation.Items[this.DropDownListNation.SelectedIndex].Text + "','" + rnrnthis.TextBox5.Text + "','" + this.TextBox6.Text + "','" + this.bumen.Itemsrnrn[this.DropDownListNation.SelectedIndex].Text + "','" + this.TextBox7.Text + "','" + rnrnRadioButtonList2.SelectedItem.Text + "')"))rn rn connection.Open();rn command.Connection = connection;rn int result = (int)command.ExecuteNonQuery();rn if (result != 0)rn rn JScript.AlertAndRedirect("登录成功!", "Login.<em>asp</em>x"); rnrn rn elsern rn JScript.AlertAndRedirect("登录失败,请重新输入您的用户名和密码!", "#");rn rn rn rn rnrn[color=#FF0000]rn 乞求高手前来赐教[/color]
Oracle数据库DBA专题技术精粹3下载
Oracle数据库DBA专题技术精粹3,DBA学习的帮手! 相关下载链接:[url=//download.csdn.net/download/kevin_78/3799753?utm_source=bbsseo]//download.csdn.net/download/kevin_78/3799753?utm_source=bbsseo[/url]
sas的几本书下载
sas的好书,这是第二部,建有一些基础的人来看 相关下载链接:[url=//download.csdn.net/download/zoi1984/4412892?utm_source=bbsseo]//download.csdn.net/download/zoi1984/4412892?utm_source=bbsseo[/url]
XP系统Internet 信息服务下找不到frontpage 2000 服务器扩展的解决方法下载
XP系统Internet 信息服务下找不到frontpage 2000 服务器扩展的解决方法 相关下载链接:[url=//download.csdn.net/download/liuyu121/4571903?utm_source=bbsseo]//download.csdn.net/download/liuyu121/4571903?utm_source=bbsseo[/url]
相关热词 c# 线程结束时执行 c# kb mb 图片 c# 替换第几位字符 c#项目决定成败 c# 与matlab c# xml缩进 c#传感器基础 c#操作wps c# md5使用方法 c# 引用父窗口的组件
我们是很有底线的