| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1203 人关注过本帖
标题:新人求 textbox中值与access中值比较
只看楼主 加入收藏
brightmoon
Rank: 1
等 级:新手上路
帖 子:61
专家分:0
注 册:2008-8-14
结帖率:94.44%
收藏
 问题点数:0 回复次数:3 
新人求 textbox中值与access中值比较
textbox中值与数据库的值比较,请指示,如何改?
        string thiscncode=cn_SoftCodeTextBox.Text.Trim();
                OleDbConnection thisconn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + System.Windows.Forms.Application.StartupPath + "/CnEduCode.mdb");
                thisconn.Open();//打开连接
                OleDbCommand mycomm = new OleDbCommand();
                OleDbCommand thiscomm = thisconn.CreateCommand();

                = "select Cn_SoftCode from Cn_SoftWare where Cn_SoftCode =" + thiscncode + "";
               
               
               
                OleDbDataReader thisread = mycomm.ExecuteReader();

                if (thisread.Read())
                {
                    MessageBox.Show("软件编号已存在,请重新输入!");
                    thisread.Close();
                    return;
                }
                else
                {
                    string article = "insert into Cn_SoftWare (Cn_SoftName,Cn_Remark,Cn_SoftCode) values('" + cn_SoftNameTextBox.Text + "','" + cn_RemarkTextBox.Text + "' ,'" + cn_SoftCodeTextBox.Text + "')";

                    OleDbCommand comm = new OleDbCommand(article, thisconn);//创建Command命令对象

                    comm.ExecuteNonQuery();//执行命令

                    MessageBox.Show("添加完成!");

运行出错图如下:
图片附件: 游客没有浏览图片的权限,请 登录注册


[[it] 本帖最后由 brightmoon 于 2008-11-21 14:31 编辑 [/it]]
搜索更多相关主题的帖子: 中值 textbox access 新人 
2008-11-21 14:20
梦心
Rank: 4
来 自:福建平和
等 级:贵宾
威 望:13
帖 子:1910
专家分:0
注 册:2007-5-11
收藏
得分:0 
= "select Cn_SoftCode from Cn_SoftWare where Cn_SoftCode =" + thiscncode + "";
这句改为:
= "select Cn_SoftCode from Cn_SoftWare where Cn_SoftCode ='" + thiscncode + "'";

我清高和我骄傲的倔强,在风中大声的唱:我不听,我不听~~做我自己最特别,呼呼~~啦啦~~~
我的博客园地址: [url]http://[/url]
2008-11-21 17:02
brightmoon
Rank: 1
等 级:新手上路
帖 子:61
专家分:0
注 册:2008-8-14
收藏
得分:0 
问题还是一样!在哪初始化?
2008-11-21 17:55
brightmoon
Rank: 1
等 级:新手上路
帖 子:61
专家分:0
注 册:2008-8-14
收藏
得分:0 
string thiscncode=cn_SoftCodeTextBox.Text.Trim();
                OleDbConnection thisconn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + System.Windows.Forms.Application.StartupPath + "/CnEduCode.mdb");
                //thisconn.Open();//打开连接
                OleDbCommand mycomm = new OleDbCommand();
                mycomm.Connection = thisconn;//初始化connection
                //OleDbCommand thiscomm = thisconn.CreateCommand();

                = "select Cn_SoftCode from Cn_SoftWare where Cn_SoftCode ='" + thiscncode + "'";

                thisconn.Open();//打开连接
               
                OleDbDataReader thisread = mycomm.ExecuteReader();



问题解决,不管怎么样还是谢谢!
2008-11-21 23:53
快速回复:新人求 textbox中值与access中值比较
数据加载中...
 
   



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

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