如何使用相同的texbox更新数据? [英] How to update data using same texboxes?

查看:106
本文介绍了如何使用相同的texbox更新数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我是刚开始使用C#的人,也是oracle.我正在c#上开发电话簿.我正在使用Oracle DB.我已经完成插入,删除,搜索.但是,我无法更新信息.请帮我.这是我的第一个问题.抱歉,我的无知.
我在网格表上列出了记录.然后,我双击网格表上任何记录的左侧.然后打开填充当前记录信息的更新面板.直到这里都没有问题.但是我的更新按钮不起作用.
这是我的更新按钮代码.

 OracleConnection con =  OracleConnection(" );
           con.Open();
           字符串查询= "  + txtGnclAd.Text.ToUpper()+ "  + txtGnclSoyad. Text.ToUpper()+ "  + txtGnclYas.Text.ToUpper()+ "  + txtGnclCep.Text.ToUpper()+  ',EV_NO ='" + txtGnclEv.Text.ToUpper()+  ',DOGUMYERI ='" + txtGnclDogumYeri.Text.ToUpper()+  'WHERE AD ='" ++  'AND SOYAD ='" + txtGnclSoyad.Text.ToUpper()+ "  + txtGnclYas.Text.ToUpper()+ "  + txtGnclCep.Text.ToUpper()+  'AND EV_NO ='" + txtGnclCep.Text.ToUpper()+ "  + txtGnclDogumYeri.Text. ToUpper()+ " ;
           DataSet ds =  DataSet(); // 数据集
           OracleDataAdapter da =  OracleDataAdapter(query,con); //  DataAdapter olustur 
           OracleCommand cmd =  OracleCommand(query,con);
            bool  result = Convert.ToBoolean(cmd.ExecuteNonQuery());
           da.Fill(ds); //  DataAdapteri Kullanarak数据集更新日期
           con.Close();



在我的表单中,我使用的是相同的文本框.我将添加两个ss,希望对您有所帮助.
第一个SS:
http://www.imagetoo.com/images/ss1aua.png
第2个SS:
http://www.imagetoo.com/images/ss2vuv.png
我需要帮助. Thanx.

解决方案

亲爱的图兰,

表中是否有任何标识字段,请根据标识字段(而不是Textfield)更新记录.并尝试使用参数化查询,因此没有SQL注入会破坏您的数据.

字符串查询= "  + txtGnclAd. 文本 .ToUpper()+ "  + txtGnclSoyad."   + txtGnclYas.文本 .ToUpper()+ " ',CEP_NO ='" + txtGnclCep."  ',EV_NO ='" + txtGnclEv." "  </code>";  pre> 


谢谢
Ashish


尝试一下

 OracleConnection con =  OracleConnection(" );
con.Open();
字符串查询= 字符串 .Format(" 更新TEL_REHBERI SET AD ='{0}',SOYAD ='{1}',YAS ='{2}',CEP_NO ='{3}',EV_NO ='{4 }',DOGUMYERI ='{5}',其中AD ='{0}'并且SOYAD ='{1}'和YAS ='{2}'并且CEP_NO ='{3}'和EV_NO ='{4}' AND DOGUMYERI ='{5}'",txtGnclAd.Text.ToUpper(),txtGnclSoyad.Text.ToUpper(),txtGnclYas.Text.ToUpper(),txtGnclCep.Text.ToUpper(),txtGnclEv.Text. ToUpper(),txtGnclDogumYeri.Text.ToUpper());

DataSet ds =  DataSet(); // 数据集
OracleDataAdapter da =  OracleDataAdapter(query,con); //  DataAdapter olustur 
OracleCommand cmd =  OracleCommand(query,con);
 bool  result = Convert.ToBoolean(cmd.ExecuteNonQuery());
da.Fill(ds); //  DataAdapteri Kullanarak数据集更新日期
con.Close();


有人可以解决吗?请


Hi everyone,

I am newly started C# and also oracle. I am developing a phone book at c#. I am Using Oracle DB. I have completed insert, delete, search. However, I cant update the information. Please help me. That is my first question. Sorry for my ignorance.
I list the records on a gridtable. Then I double click the left side of any record on grid table. Then the update panel which is filled the information of the current record is opened. There is no problem until here. However my update button does not work.
Here is my Update Button Code.

OracleConnection con = new OracleConnection("Data Source=O10G;User Id=plsql_staj;Password=*****;");
           con.Open();
           string query = "UPDATE TEL_REHBERI SET AD ='" + txtGnclAd.Text.ToUpper() + "' , SOYAD ='" + txtGnclSoyad.Text.ToUpper() + "' , YAS = '" + txtGnclYas.Text.ToUpper() + "' , CEP_NO = '" + txtGnclCep.Text.ToUpper() + "' , EV_NO = '" + txtGnclEv.Text.ToUpper() + "', DOGUMYERI = '" + txtGnclDogumYeri.Text.ToUpper() + "' WHERE AD ='"++ "' AND SOYAD = '" + txtGnclSoyad.Text.ToUpper() + "' AND YAS ='" + txtGnclYas.Text.ToUpper() + "' AND CEP_NO = '" + txtGnclCep.Text.ToUpper() + "' AND EV_NO ='" + txtGnclCep.Text.ToUpper() + "' AND DOGUMYERI = '" + txtGnclDogumYeri.Text.ToUpper() + "' ";
           DataSet ds = new DataSet();// Dataset
           OracleDataAdapter da = new OracleDataAdapter(query, con); // DataAdapter olustur
           OracleCommand cmd = new OracleCommand(query, con);
           bool result = Convert.ToBoolean(cmd.ExecuteNonQuery());
           da.Fill(ds); // DataAdapteri Kullanarak Dataset içindeki Verilere erişti
           con.Close();



In my form I am using the same textboxes. I will Add two ss and hope this will help.
1st ss:
http://www.imagetoo.com/images/ss1aua.png
2nd ss:
http://www.imagetoo.com/images/ss2vuv.png
I need Help. Thanx.

解决方案

Dear turan,

Is there any identity field in your table, update your record on basis of an identity field not with Textfield. and Try to use parameterized query, so No SQL injection will distroy your data.

string query = "UPDATE TEL_REHBERI SET AD ='" + txtGnclAd.Text.ToUpper() + "' , SOYAD ='" + txtGnclSoyad.Text.ToUpper() + "' , YAS = '" + txtGnclYas.Text.ToUpper() + "' , CEP_NO = '" + txtGnclCep.Text.ToUpper() + "' , EV_NO = '" + txtGnclEv.Text.ToUpper() + "', DOGUMYERI = '" + txtGnclDogumYeri.Text.ToUpper() + "' WHERE <code>id="+reheberi_ID+" </code>";




Thanks
Ashish


Try this

OracleConnection con = new OracleConnection("Data Source=O10G;User Id=plsql_staj;Password=*****;");
con.Open();
string query = string.Format("UPDATE TEL_REHBERI SET AD ='{0}', SOYAD ='{1}', YAS = '{2}', CEP_NO = '{3}' , EV_NO = '{4}', DOGUMYERI = '{5}' WHERE AD ='{0}' AND SOYAD = '{1}' AND YAS ='{2}' AND CEP_NO = '{3}' AND EV_NO ='{4}' AND DOGUMYERI = '{5}'",txtGnclAd.Text.ToUpper() , txtGnclSoyad.Text.ToUpper(), txtGnclYas.Text.ToUpper() ,txtGnclCep.Text.ToUpper() ,txtGnclEv.Text.ToUpper() , txtGnclDogumYeri.Text.ToUpper());

DataSet ds = new DataSet();// Dataset
OracleDataAdapter da = new OracleDataAdapter(query, con); // DataAdapter olustur
OracleCommand cmd = new OracleCommand(query, con);
bool result = Convert.ToBoolean(cmd.ExecuteNonQuery());
da.Fill(ds); // DataAdapteri Kullanarak Dataset içindeki Verilere erişti
con.Close();


Is there anybody to solve this? Please


这篇关于如何使用相同的texbox更新数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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