Click here to Skip to main content
15,902,635 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
How to display database text box values shown on message box in c# windows application

What I have tried:

How to display stored database text box values shown on message box in c# windows application
Posted
Updated 27-Jun-16 5:21am
Comments
ZurdoDev 27-Jun-16 11:50am    
What?

1 solution

Do you mean this one ?
C#
const string sql = "SELECT * FROM MyTable";
var dataTable = new DataTable("MyTable");
using (var sqlConnection = new SqlConnection("MyConnectionStringBlaBlaBla"))
{
  sqlConnection.Open();
  using (var sqlDataAdapter = new SqlDataAdapter(sql, sqlConnection))
  {
    sqlDataAdapter.Fill(dataTable);
  }
}
MessageBox.Show(dataTable.Rows[0].ItemArray[0].ToString());
 
Share this answer
 
Comments
Boopalslm 27-Jun-16 11:28am    
cannot display message box,
Boopalslm 27-Jun-16 11:38am    
error is came
There is no row at position 0.
jayveebishie 28-Jun-16 2:51am    
"There is no row at position 0." Meaning no record found in your SELECT statement

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