How to run basic query in C# and ASP.NET
Connect to the database, execute query command and collect row data in datareader object. Retrieve data from datareader.
SqlConnection sqlConnection1 = new SqlConnection("Your Connection String");
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "SELECT * FROM Customers";
cmd.CommandType = CommandType.Text;
cmd.Connection = sqlConnection1;
reader = cmd.ExecuteReader();
// Data is accessible through the DataReader object here.
txtControl.text = reader["field name"].ToString();
Read about this on Microsoft
This entry was posted in Software Development
. Bookmark the permalink