I am using VS2008 and .NET 3.5
This code does not seem to be getting any data. Yet, there are no errors.
Any thoughts? All of the example code seems to be VS2005Code:private void frmLog_Load(object sender, EventArgs e) { SqlDataReader rdr = null; SqlConnection conn = new SqlConnection("Data Source=PRIMERO;Initial Catalog=Techni;Persist Security Info=True;User ID=sa;Password=pacjo"); SqlCommand sqlEmp = conn.CreateCommand(); sqlEmp.CommandText = "SELECT empnum FROM Empfile ORDER BY Empnum"; // open the connection conn.Open(); // get an instance of the SqlDataReader rdr = sqlEmp.ExecuteReader(); //if rdr.HasRows then { while (rdr.Read()) { int idxID = rdr.GetOrdinal("empnum"); string idx2 = Convert.ToString(idxID); MessageBox.Show(idx2); //got a 0 here string employee = (string)rdr["empnum"]; TS1.Text = (employee); } //} // close the reader and connection rdr.Close(); conn.Close(); }
TS1 is a status strip on the form.




Reply With Quote