标题:System.Data.OleDb.OleDbConnection 并不包含 ExecuteNonQuary 的定义
取消只看楼主
qi_w2006
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2008-3-31
 问题点数:0 回复次数:1 
System.Data.OleDb.OleDbConnection 并不包含 ExecuteNonQuary 的定义
今天我照别人的代码做了个数据更新的,可是在运行时却提示:System.Data.OleDb.OleDbConnection 并不包含 ExecuteNonQuary 的定义
源代码如下:
String s1= comboBoxIncome.Text.ToString();
            String s2 = textBoxItem.Text.ToString();
            String s4 = textBoxSum.Text.ToString();
            String  s3= richTextBoxRemark.Text.ToString();
            try
            {
                if (s1 != "请选择类别" && s2 != "" && s3 != "" && s4 != "¥0")
                {
                    String strconn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=Data.mdb" ;
                    OleDbConnection oleconn = new OleDbConnection(strconn);
                    oleconn.Open();
                    String strInsert = "INSERT INTO InOut(收支,类别,项目,备注,金额(¥),日期VALUE('收',s1,s2,s3,s4,System.DateTime.Now))";
                    OleDbCommand olecom = new OleDbCommand(strInsert,oleconn);
                    oleconn.ExecuteNonQuary();
                    oleconn.Close();
                    DataSet ds = new DataSet();
                    BindingManagerBase myBind;
                    myBind=this.BindingContext[ds,"InOut"];

                    ds.Tables["InOut"].Rows[myBind.Position].BeginEdit();
                    ds.Tables["InOut"].Rows[myBind.Position].EndEdit();
                    ds.Tables["InOut"].AcceptChanges();


                    MessageBox.Show(s1 + "\n" + s2 + "\n" + s3 + "\n" + s4 + "\n" + "已加入数据库", "提示!");

                }
                else
                    MessageBox.Show("必须填满所有字段值!", "错误!");
            }catch(Exception me)
            {
                MessageBox.Show("保存数据记录发生"+me.ToString(),"错误!");
            }
搜索更多相关主题的帖子: Data OleDb System 定义 源代码 
2008-03-31 22:46
qi_w2006
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2008-3-31
得分:0 
回复 2# 的帖子
谢谢啊,可是有了新的问题,说什么语法有问题啊!!
麻烦再看看啊!
这个应该不难吧
请了……
2008-04-01 17:02



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-206442-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.837117 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved