473,407 Members | 2,306 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

update tablename set feild1=' ' where field2=(select field2 from table2 where no=' ')

I hav a problem in sql query.I m using C#.net and working on window form,Database is SqlSever.
There is a table tracking which has key_no,status as its field.
There is another table master which has slno,key_no,etc as its field.

In my form i hav a textbox in which one enters slno,so using this slno i want to get key_no from master table using Select query and then use this key_no to update the status in tracking table.

I have used the code which is written below,but it is not updating the value in the table tracking.

Expand|Select|Wrap|Line Numbers
  1. SqlConnection cn = new SqlConnection();
  2. cn.ConnectionString = "Data Source= abc ;Database= def;uid=pro;pwd=ghg";
  3. cn.Open();
  4. string sql = "update rock set status='INVG' where key_no=(select key_no from master where slno=@slno)";
  5. SqlCommand cmd= new SqlCommand(sql, cn);
  6. cmd.Parameters.AddWithValue("@slno", Convert.ToInt32(textBox2.Text)); 
  7. SqlDataAdapter ds = new SqlDataAdapter(k);
  8. ds.Fill(dd); /*dd is a instance of DataTable*/
  9. MessageBox.Show("Record updated");
  10. cn.Close();
plzzz help.........
Jul 26 '08 #1
1 1121
thanks u all for the co-operation,well i hav solved this query so there is now no need to send me reply for this query.
Jul 26 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Nick | last post by:
Im trying to insert a bunch of rows into a table. If the row already exists id like to update the row 'counter'. For example... INSERT INTO table1 SELECT field1, field2 FROM table2 ON...
8
by: Nick | last post by:
Im trying to insert a bunch of rows into a table. If the row already exists id like to update the row 'counter'. For example... INSERT INTO table1 SELECT field1, field2 FROM table2 ON...
5
by: parwal.sandeep | last post by:
Hello grp! i'm using INNODB tables which are using frequently . if i fire a SELECT query which fetch major part of table it usually take 10-20 seconds to complete. in mean time if any UPDATE...
11
by: cooperkuo | last post by:
Dear all, I have a question about ADO in the subform. I know how to use ADO to insert/update/select data into the sigin form, but wehn I try to do it in the form with subform((Datasheet). I don't...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.