i ve make table in sql server and wanted to reterive one by one row in windows form... in case ov correct there must be inclement in score....... but question is not appaering in lable1 in windows form as well as options in radio buttons... plz plz help me out
private void Form1_Load(object sender, EventArgs e)
{
string constring ="Server=TAHIRA-7B0ECEAE\\SQLEXPRESS;integrated security=SSPI;database=MCQ";
SqlConnection conn = new SqlConnection (constring);
conn.Open();
string Sql = "select * from table_1";
SqlCommand cmd = new SqlCommand(Sql,conn);
SqlDataReader reader = cmd.ExecuteReader();
while(reader.Read());
label1.Text=reader[0];
radioButton1.Text=reader[1];
radioButton2.Text=reader[2];
radioButton3.Text=reader[3];
cmd.ExecuteNonQuery();
Loading

Suthish NairRank #92 · 22.8K reputationPosted Apr 20, 2011, 1:21 PM EDT
tAhIra sgd11 reputationPosted Apr 21, 2011, 1:29 PM EDT
Jonathas Sucupira122 reputationPosted Apr 21, 2011, 2:31 PM EDT
private void Form1_Load(object sender, EventArgs e)
{
string constring ="Server=TAHIRA-7B0ECEAE\\SQLEXPRESS;integrated security=SSPI;database=MCQ";
SqlConnection conn = new SqlConnection (constring);
conn.Open();
string Sql = "select * from table_1";
SqlCommand cmd = new SqlCommand(Sql,conn);
Try
{
SqlDataReader reader = cmd.ExecuteReader();
while(reader.Read())
{
label1.text = reader["the tabel field1"].ToString();
radiobutton1.text = reader["the table field2"].tostring();
//ETC
}
}
Catch (Exception e)
{
response.write("Error: " + e.message);
}
tAhIra sgd11 reputationPosted Apr 22, 2011, 7:14 AM EDT