C#调用CodeSoft打印条码 ,未将对象引用设置到对象的实例怎么解决?

public bool PrintMAC(DataTable dtb, string barcode, string Prefix, string SerNum, int ptnum, string model, out string error)
{
Kill("lppa");
model = AppDomain.CurrentDomain.BaseDirectory + model;//取当前应用程序域运行的目录
LabelManager2.ApplicationClass PrintApp = new LabelManager2.ApplicationClass();

    try
    {
        LabelManager2.Document PrintDoc = PrintApp.ActiveDocument;
        PrintDoc = PrintApp.Documents.Open(model, false);
        if (PrintDoc == null)
        {
            error = "模版未找到";
            return false;
        }

        if (!string.IsNullOrEmpty(barcode))
        {
            PrintDoc.Variables.Counters.Item(barcode).Prefix = Prefix;
            PrintDoc.Variables.Counters.Item(barcode).Value = SerNum;
        }

        for (int j = 0; j < dtb.Rows.Count; j++) //行
        {
            for (int i = 0; i < dtb.Columns.Count; i++) //列
            {
                try
                {
                    string col = dtb.Columns[i].ColumnName.ToString();
                    string txt = dtb.Rows[j][col].ToString();
                    PrintDoc.Variables.FormVariables.Item(col).Value = txt;
                }
                catch (Exception ex)
                {
                    error = ex.Message;
                    return false;
                }
            }
            PrintDoc.PrintDocument(1);

        }
        error = "打印成功";
        return true;

    }
    catch (Exception ex)
    {
        error = ex.Message;
        return false;
    }
    finally
    {
        PrintApp.Documents.CloseAll(false);
        PrintApp.Quit();
    }

}

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
codesoft问题 “未将对象引用设置到对象的实例”
小弟最近在编写一个c#调用codesoft的程序,需要读取codesoft文件中的变量,然后在c#程序中赋值,最后再打印。但是遇到下面的问题 请大哥哥们 帮忙给看一下?万分感谢!rnrnrnrnApplicationClass lbl = new ApplicationClass();rnrn tryrn rn lbl.Documents.Open(@";", false);rn //Document doc = new Document();rn Document doc = lbl.ActiveDocument;rn doc.Variables.FormVariables.Item("变量0").Value = textBox1.Text.Trim();rn doc.Variables.FormVariables.Item("变量1").Value = "1234325435465676576876876";rn doc.PrintDocument(1);rn doc.Close(false);rn rn catch (Exception ex)rn rn MessageBox.Show(ex.Message);rn lbl.Quit();rn rn[img=https://img-bbs.csdn.net/upload/201805/16/1526460002_930306.png][/img]rnrnrn
解决“c#:未将对象引用设置到对象的实例”
在用c#操作数据库的时候遇到了该问题,由此记录一下解决方法: 调试的时候无法连接到数据库,提示“未将对象引用设置到对象的实例”。我查看我的代码,本来想的是“没问题啊,明明已经将数据库连接语句实例化了”。知道后来我单步调试查看变量的值,才发现了问题所在: 看到了没,有两个mysqcon,继续调试,发现: 一个被赋值了,即实例化,而另一个,仍旧为空。说明我的代码里有两个mysqlcon。再来看看...
未将对象引用设置到对象的实例。 怎么解决
代码String RequestStrsql = Request.QueryString["Strsql"].ToString() ;rn如果写成String RequestStrsql = new String();rn也不行 rn请高手指点
未将对象引用设置到对象的实例,怎么解决??
int re=0;rnstring buf=new String('\0',1024);rnint siz=1024;rnre=WinApi.GetComputerName(buf,siz);//在这句时出错rnbuf.Substring(0,buf.IndexOf('\0'));rnDebug.WriteLine(buf);rn
怎么解决未将对象引用设置到对象的实例?
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 rnrn异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。rnrn源错误: rnrnrn行 94: public DataTable GetNewsList()rn行 95: rn行 96: [color=#FF0000] Database db = DatabaseFactory.CreateDatabase();[/color]行 97: string strSql = "select * from Shop_News";rn行 98: DbCommand cmd = db.GetSqlStringCommand(strSql);rn rnrn源文件: E:\毕业设计\Shop.Bussiness\News.cs 行: 96 rn另外有没有会C#的朋友啊,大家交流交流rnrn
未将对象引用设置到对象的实例 怎么解决
做了一个 修改已经上传音乐的页面。在写绑定信息是 string _id = Request.QueryString["id"].ToString().Trim();这句总是提示 未将对象引用设置到对象的实例。请问怎么解决。rn代码如下:rnprotected void PageInit()rn rn [color=#FF0000]string _id = Request.QueryString["id"].ToString().Trim();[/color] _id = BasePage.CheckStr(_id);rn tbMusicDal tbMusicDal1 = new tbMusicDal();rn DataSet ds1 = tbMusicDal1.GetList(string.Format("id=0", _id));rn if(ds1.Tables[0].Rows.Count > 0)rn rn DataRow dr = ds1.Tables[0].Rows[0];rn tbName.Text = dr["Name"].ToString().Trim();rn tbGroupName.Text = dr["Name"].ToString().Trim();rn tbAuthors.Text = dr["Authors"].ToString().Trim();rn tbLyrics.Text = dr["Contents"].ToString().Trim();rn lb_path.Text = dr["MusicUrl"].ToString().Trim();rn //绑定下拉列表rn string strSql = "select * from tbMusicClass";rn SqlDataAdapter sda = new SqlDataAdapter(strSql, BasePage.GetConn());rn DataSet ds = new DataSet();rn sda.Fill(ds, "tbMusicClass");rn string _html = "";rn foreach (DataRow draaa in ds.Tables[0].Rows)rn rn if (dr["ParentId"].ToString().Trim() == draaa["id"].ToString().Trim())rn rn _html += string.Format("1", draaa["id"].ToString(), draaa["ClassName"].ToString());rn rn elsern rn _html += string.Format("1", draaa["id"].ToString(), draaa["ClassName"].ToString());rn rn rn _html += "";rn ltr_class.Text = _html;rn rn
未将对象引用设置到对象的实例 怎么解决??
Calendar cal = (Calendar)Page.Master.FindControl("Calendar1");rn DateTime date = cal.SelectedDate;rn Label la = (Label)DataList2.FindControl("Label1");rn rn la.Text = date.ToString();rn这段代码运行之后出现未将对象引用设置到对象的实例 怎么解决??rn望各位高手指点
未将对象引用设置到对象的实例?怎么解决?
放在:if(!Page.IsPostBack)rnrntongji();rnrnrn如下:rnprivate void tongji()rnrnif(Request.UrlReferrer.ToString().Substring(0,20).ToString()!="http://www.ip808.com")rnrnstring UserHostAddress=Request.UserHostAddress ;rnOpenDatabase();rnstring sql="insert into tongji(Cip,Ctime)values'"+UserHostAddress+"','"+System.DateTime.Now+"')";rn SqlCommand cmd=new SqlCommand(sql,cn);rn cmd.ExecuteNonQuery();rn cn.Close();rn rn rnrn提示这行:rnif(Request.UrlReferrer.ToString().Substring(0,20).ToString()!="http://www.ip808.com")rn未将对象引用设置到对象的实例rn怎么解决??
C#调用Codesoft批量打印条码实例
C#调用Codesoft批量打印条码实例,已经调试通过,执行数据库脚本后可以直接运行,只需要设置模板文件就可以
c#编程怎么解决未将对象引用设置到对象的实例
[img=https://img-bbs.csdn.net/upload/201705/07/1494152307_437795.png][/img]
C# winform 未将对象引用设置到对象的实例。 该怎么解决
[code=C#]private void 新建名片ToolStripMenuItem_Click(object sender, EventArgs e)rn rnrn FrmAddCode addcode = new FrmAddCode();rn addcode._mingpianjia = treeView1.SelectedNode.Tag.ToString();rn rn addcode.ShowDialog();rnrn [/code]rn总是提示[code=C#]treeView1.SelectedNode.Tag.ToString();[/code]这一句错误“[color=#FF0000]未将对象引用设置到对象的实例[/color]”rn不知道是不是只有treeView1才能用treeView1.SelectedNode.Tag 。还是怎么回事。。rn请各位指点下。上面代码中 怎样才能获取到treeView1.SelectedNode.Tag值,而不出错([color=#FF0000]不是在treeView1的时间下使用[/color])
未将对象引用设置到对象的实例??如何解决??
在版主后台管理信息中,想要提供版主修改推荐信息的功能,就是版主可以修改哪条信息是推荐信息,哪条信息是非推荐信息,在gridview中,用一个checkbox控件绑定是否为推荐,推荐用打勾,非推荐为不打勾。版主可以进行修改。在CheckBox1_CheckedChanged点击事件中,老是提醒说“未将对象引用设置到对象的实例”的错误。我现在把代码发给各位高手看下,看能不能帮我解决。很急啊,老师就要检查了,要做一点后台管理给老师看看,我好交差啊。。谢谢。。。rnprotected void CheckBox1_CheckedChanged(object sender, EventArgs e)rn rn CheckBox chk = sender as CheckBox;rn GridViewRow row = chk.NamingContainer as GridViewRow;rn string sqlconstr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;rn SqlConnection conn = new SqlConnection(sqlconstr);rn conn.Open();rn string if_recommend = "0";rn CheckBox CheckBox1 = (CheckBox)(row.FindControl("CheckBox1"));rn if (CheckBox1.Checked == true)rn rn if_recommend = "1";rn rn string sqlstr = "update [Message] set if_recommend='" + if_recommend + "'";rn sqlstr += " where Mid='" + gvNewsList.DataKeys[row.RowIndex].Value.ToString() + "'";rn SqlCommand cmd = new SqlCommand(sqlstr, conn);rn cmd.ExecuteNonQuery();rn gvNewsList.EditIndex = -1;rn conn.Close();rn bindgrid();rn rnrn小妹我在这里谢谢大家了。。。 rn
未将对象引用设置到对象的实例,如何解决?
请教下各位今天发现个问题,出问题的模块是这样的rnrn窗口上放了两个button 和两个pictureboxrnrn一个button用于读取图片到picturebox1rn另一个button2用于修改图片显示到picturebox2rnrn问题就出来了:rnrn在button2_click里rnrnbitmap a = new bitmap(picturebox1.image);rnbitmap b = new bitmap(picturebox2.image);rnrn//图像处理代码rnrn每次点击button2的时候就报错,rn错误指向“bitmap b = new bitmap(picturebox2.image);” rn提示:未将对象引用设置到对象的实例rn使用new关键字创建对象的实例rn在调用方法前通过检查对象是否为null
“未将对象引用设置到对象的实例。”如何解决?
img=C:\Documents and Settings\XY\桌面\QQ截图未命名2.bmp][/img]rnrnDbCommand cmd = Provider.CreateCommand();指向我这句? rn怎么解决呢?
未将对象引用设置到对象的实例。如何解决?
“/myweb”应用程序中的服务器错误。rn--------------------------------------------------------------------------------rnrn未将对象引用设置到对象的实例。 rn说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 rnrn异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。rnrn源错误: rnrnrn行 49: // 在新会话启动时运行的代码rn行 50: Application.Lock();rn行 51: [color=#FF0000]Application["Counter"] = (int)Application["Counter"] + 1;[/color]rn行 52: Application["OnLineCounter"] = (int)Application["OnLineCounter"] + 1;rn行 53: Session.Timeout = 1;rn rn
未将对象引用设置到对象的实例
起因:文件中的类都不能进行设计,因此未能为该文件显示设计器。设计器检查出文件中有以下类: FormMain --- 未能加载基类“WinForm.Win.FormsBase.FormMainBase”。请确保已引用该程序集并已生成所有项目我用了一个小时找百度。这个的解决方法,就是将你删除过的一个窗体,再添加上就好了。。。。有点生气的。。然后出现了:未将对象引用设置到对象的实例的问题这个问题的解决方...
未将对象引用设置到对象的实例。
我在一个页面定义一个DataTable表 里面已经有数据,把他传到用户控件的后天代码?我是这样写的,为什么老是报出未将对象引用设置到对象的实例。难道穿过来的表是空的吗?[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();//就是这里出现问题的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
未将对象引用设置到对象的实例??
未将对象引用设置到对象的实例。 rn说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 rnrn异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。rnrn源错误: 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.aspx.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.aspx"); rnrn rn elsern rn JScript.AlertAndRedirect("登录失败,请重新输入您的用户名和密码!", "#");rn rn rn rn rnrn[color=#FF0000]rn 乞求高手前来赐教[/color]
未将对象引用设置到对象的实例..
我知道这个很简单 ,但是..但是 我百度了好久都不会- -~ rn求解-,-rn private string connectionstring = ConfigurationManager.ConnectionStrings["connection"].ConnectionString;rn protected void Page_Load(object sender, EventArgs e)rn rn if (!IsPostBack)rn rn show();rn rn rn protected void show()rn rn string m_id = Request["m_id"].ToString();rn SqlConnection con = new SqlConnection(connectionstring);rn con.Open();rn string selectmessage = "select * from message where m_id='" + m_id + "'";rn SqlCommand cmd = new SqlCommand(selectmessage, con);rn SqlDataReader dr = cmd.ExecuteReader();rn if (dr.Read())rn rn this.Tbname.Text = dr["m_name"].ToString();rn this.Tbsubject.Text = dr["m_subject"].ToString();rn this.Tbcontent.Text = dr["m_content"].ToString();rn this.TBreplay.Text = dr["m_replay"].ToString();rn rn dr.Close();rn con.Close();rn
未将对象引用设置到对象实例
我是新手 不知道哪出问题了 我看了 有NULL出现 但是不知道怎么改啊 rn 弹出一个对话框 显示"用户代码未处理NullferenceExceotion"rn具体代码如下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.Web.Configuration;rnusing System.Data.SqlClient;rnrnpublic partial class _Default : System.Web.UI.Page rnrn protected void Page_Load(object sender, EventArgs e)rn rn string connectionString = WebConfigurationManager.ConnectionStrings["Test"].ConnectionString;rn SqlConnection con = new SqlConnection(connectionString);rn string sql = "select * from '操作员信息'";rn SqlCommand cmd = new SqlCommand(sql, con);rn 显示.Text = sql;rn rn protected void Button1_Click(object sender, EventArgs e)rn rnrn rnrn
未将对象引用设置到对象的实例????????????
未将对象引用设置到对象的实例。 rn说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 rnrn异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。rnrn源错误: rnrnrn行 82:Db AddDb=new Db();rn行 83:string Sql1;rn行 84:Sql1="update Site_Info set SiteName='"+tbxSiteName.Text+"',SiteManager='"+tbxSiteManage.Text+"',"+rn行 85:"SiteUrl='"+tbxSitePwd.Text+"',ManagePwd='"+tbxSitePwd.Text+"' where Id="+Int32.Parse(lblSiteId.Text);rn行 86: if (AddDb.ExeSql(Sql1)==1)rn rnrnrn行 85:显示红色,什么原因啊
未将对象引用设置到对象的实例?
我做了个Repeater的批量删除,rn页面上是这样的rn rn rn rn rn rn rn rn <%#DataBinder.Eval(Container.DataItem,"Id") %>rn <%#DataBinder.Eval(Container.DataItem,"ISBN") %>rn <%#DataBinder.Eval(Container.DataItem,"bookName") %>rn <%#DataBinder.Eval(Container.DataItem,"price") %>rn <%#DataBinder.Eval(Container.DataItem,"number") %>rn <%#DataBinder.Eval(Container.DataItem,"myang") %>rn <%#DataBinder.Eval(Container.DataItem, "bookSpec")%>rn rn rnrn rncs里代码:rnprotected void Button1_Click(object sender, EventArgs e)rn rn //Button1.Attributes["onclick"] = "return confirm('你确实要删除吗?')";rn rn string ID= "";rn foreach (RepeaterItem item in this.Repeater1.Items)rn rn CheckBox ck = (CheckBox)item.FindControl("CheckBox");rn if (ck.Checked)rn rn HtmlInputHidden inputhidden = (HtmlInputHidden)item.FindControl("fieldname ");rn ID += inputhidden.Value.Trim() + ",";rn rn rn if (ID.Length == 0)rn rn this.Page.RegisterStartupScript(" ", " ");rn rn elsern rn ID = ID.Remove(ID.Length - 1, 1);rn Info.DelId = ID;rn Fun fun = new Fun();rn fun.DelshaixuanId();rn Response.Write(" ");rn rn rn rnrnrnrnrn它说我这句话ID += inputhidden.Value.Trim() + ",";rn未将对象引用设置到对象的实例。什么意思啊?
相关热词 c++和c#哪个就业率高 c# 批量动态创建控件 c# 模块和程序集的区别 c# gmap 截图 c# 验证码图片生成类 c# 再次尝试 连接失败 c#开发编写规范 c# 压缩图片好麻烦 c#计算数组中的平均值 c#获取路由参数