473,498 Members | 2,021 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

retrieving data

13 New Member
hai


in form1 i have 3 textboxes...

when i enter value in first box
i should get other two boxes to have values from the database...
i used select and update commands for that
but i am not able to do...
help me
Feb 1 '07 #1
5 1060
kenobewan
4,871 Recognized Expert Specialist
You will need to activate a function in your source code based on a user initiated event from their using first text box...

Hope that this helps.
Feb 1 '07 #2
joyce85
13 New Member
private void UpdateButton_Click(object sender, System.EventArgs e)
{
try
{
con=new OleDbConnection(conString);
string str="Select First_Name,ID From Employee where SI_No=("+textBox1.Text+")";
con.Open();
cmd=new OleDbCommand(str,con);
rdr=cmd.ExecuteReader();
rdr.Read();
textBox2.Text=rdr[0].ToString();
textBox3.Text=rdr[1].ToString();
rdr.Close();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
con.Close();
}

try
{
con=new OleDbConnection( constring);
string str1="Update Employee Set First_Name=('"+textBox2.Text+"'),ID=("+textBox3.Te xt+") where SI_No=("+textBox1.Text+")";
con.Open();

cmd1=new OleDbCommand(str1,con);
cmd1.ExecuteNonQuery();
//MessageBox.Show("Record updated");
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
con.Close();
}

}


is it correct?


because i want to retrive data frm database and need to update it at the same time...

how could i do that?
Feb 1 '07 #3
kenobewan
4,871 Recognized Expert Specialist
This looks close... If you get an error on the first you will want to exit the function as the second won't work. Good use of try catch and opening and closing connection. I would only expect a syntax error - have you tested?
Feb 1 '07 #4
joyce85
13 New Member
This looks close... If you get an error on the first you will want to exit the function as the second won't work. Good use of try catch and opening and closing connection. I would only expect a syntax error - have you tested?


thanks for your reply....
i finished thay...
Feb 1 '07 #5
joyce85
13 New Member
thanks for your reply....
i finished thay...


how can i get values at a selected index of a dataGrid...but i am able get the index not the values
Feb 1 '07 #6

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

Similar topics

0
1560
by: Alistair | last post by:
Hi all, I am creating a database based site that keeps track of books, who has read them and the comments they have. After a little help in M.P.I.asp.DB I managed to create a database (access...
1
2254
by: Rushabh Dadbhawala | last post by:
Problem: I am fetching data from the database, storing it in a dataSet, and binding it with a Data Grid. The DataGrid controls allows sorting. The problem is that when the data is sorted on one...
5
2217
by: aniket_sp | last post by:
i am using a data adapter and a dataset for filling and retrieving data into .mdb database. following is the code..... for the form load event Dim dc(0) As DataColumn Try If...
0
1224
by: kid4rilla | last post by:
I can successfully write the binary data to an image data type, and successfully retrieve it, but when I attempt to play the file in media player after retrieving it, I get the file type isn't...
1
1323
by: Dave | last post by:
Can some help me out retrieving word, pdf, etc. docs and streaming to the browser? I'm saving the docs as an image data type along with it's original filename and retrieving them using a...
0
2020
by: Andy | last post by:
Hi All. I'm working for a company that has set out a guideline for retrieving data from a database. Nobody can explain to me the reason for the following. When retrieving a set of records...
6
19922
by: AlveenX | last post by:
Hi, I am trying to pick a Guid from a data row using the following code: foreach(DataRow row in MyDataTable.Rows) { (Guid)row }
1
9432
by: jimmyfo | last post by:
Hi, I recently wrote an ASP.Net web application in VS2005 and published (using VS2005 Publish feature) it to a relatively clean machine with ASP.Net 2.0 and MDAC 2.8 installed on it. However, when...
5
1960
by: Sanjay Pais | last post by:
I have a table with over 1.3 million rows. I am retrieving only 20 at a time using the with - over clauses In query analyser, the data is retrieved in under a second. When retrieving using the...
1
2419
by: san123456789 | last post by:
Hi, Im using a MS SQL server to store images... Im creating a windows form application using C#. I need to store and retrieve images from the database. This is my code to store images: ...
0
6993
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
7162
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7197
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6881
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1411
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
650
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
287
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.