Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
when i select emp id in search box that id details(employee datas retrive from database) how to come message box in window application c#

da.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
MessageBox.Show("Eid:"+"Ename:"+"Esalary:");
Posted

Try this

C#
MessageBox.Show("Eid:{0}, Ename:{1}, Esalary:{2}",Convert.tostring(ds.Tables[0].Rows[0]["Eid"].ToString()),Convert.tostring(ds.Tables[0].Rows[0]["Ename"].ToString()),Convert.tostring(ds.Tables[0].Rows[0]["Esalary"].ToString()));
 
Share this answer
 
v2
Comments
Member 10918596 4-Jul-14 6:33am    
Error- Argument 4: cannot convert from 'string' to 'System.Windows.Forms.MessageBoxIcon'


above error came ..wht can i do
Member 10918596 4-Jul-14 7:18am    
MessageBox.Show("Eid='"+ds.Tables[0].Rows[0][0].ToString()+"'",
"Ename='"+ds.Tables[0].Rows[0][1].ToString()+"'");
If you want to display only single record in messagebox you can display it like below:-

MessageBox.Show("Eid:{0}, Ename:{1}, Esalary:{2}",ds.Tables[0].Rows[0]["Eid"].ToString(),ds.Tables[0].Rows[0]["Ename"].ToString(),ds.Tables[0].Rows[0]["Esalary"].ToString());
 
Share this answer
 
Comments
Member 10918596 4-Jul-14 6:09am    
Error-1
Argument 3: cannot convert from 'string' to 'System.Windows.Forms.MessageBoxButtons'
Error-2
The best overloaded method match for 'System.Windows.Forms.MessageBox.Show(string, string, System.Windows.Forms.MessageBoxButtons)' has some invalid arguments


two errors came ...wht can i do..
Do you need all data in the message box or just one data.
if one data than you can use below code

ds.Tables[0].Rows[0]["YourColumnName"].ToString()
above code will give you the data element at table 0 and row 0
 
Share this answer
 
Comments
Member 10918596 4-Jul-14 6:08am    
Error-1
Argument 3: cannot convert from 'string' to 'System.Windows.Forms.MessageBoxButtons'
Error-2
The best overloaded method match for 'System.Windows.Forms.MessageBox.Show(string, string, System.Windows.Forms.MessageBoxButtons)' has some invalid arguments


two errors came ...wht can i do..
suhel_khan 4-Jul-14 6:25am    
take all data in one string and than show in msg box
Member 10918596 4-Jul-14 6:29am    
Give example pls
suhel_khan 4-Jul-14 6:34am    
string sAllvalue="Eid:{0}, Ename:{1}, Esalary:{2}",ds.Tables[0].Rows[0]["Eid"].ToString(),ds.Tables[0].Rows[0]["Ename"].ToString(),ds.Tables[0].Rows[0]["Esalary"].ToString())";
MessageBox.Show(sAllvalue);

Try this :)
Member 10918596 4-Jul-14 7:03am    
lot of error came .pls solve my problem pls

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900