Problem I traced is 1) The SQL Command is "INSERT" instead of select command. Insert Command insert data into tables and return the number of records inserted. 2) DataReader returns object. You have to convert the same into the data type you want eg. code { object obj = dr.read(); Convert.ToString(obj); } SO YOUR REQUIRED CODE SHALL BE LIKE FOLLOWS ---- SqlConnection con = new SqlConnection("server=AAB;database=ab;uid=sa;pwd=pass"); con.Open(); SqlCommand cmd = new SqlCommand("SELECT * FROM myTable", con); SqlDataReader dr = cmd.ExecuteReader(); while (!dr.IsDbNull()) { Object obj = dr.Read(); label1.Text= obj.ToSring(); } dr.Close(); --- try and reply.
modified on Saturday, May 30, 2009 4:09 AM