Tim Field Posted September 1, 2005 Posted September 1, 2005 Hi all, I'm doing some pretty standard stuff here. The database is ok and the proc returns 200 records when I run this directly in query analyser. The datareader is returning the recordset but I'm getting no records. Any ideas? Thanks! Tim -------------------------------------------------------- SqlConnection mySqlConnection = new SqlConnection(); string strConn = ""; strConn = "Data Source=" + this.textBoxInstance.Text + ";" ; strConn += "DataBase= " + this.textBoxDBName.Text + ";" ; //strConn += " Integrated Security=SSPI ;" ; strConn += "User ID = sa;" ; strConn += " connection timeout=10000" ; mySqlConnection.ConnectionString = strConn; SqlCommand cmd = mySqlConnection.CreateCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "sta_pix_Create_Adnos"; SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd; cmd.Connection.Open(); // use the sqldatareader dr = cmd.ExecuteReader(); string hello; if(dr.Read()) { // This will be the UPN hello = dr.GetString(0); // first column } Quote
Administrators PlausiblyDamp Posted September 1, 2005 Administrators Posted September 1, 2005 If you step through the code does dr.Read() evaluate to true or false? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Tim Field Posted September 1, 2005 Author Posted September 1, 2005 It evaluates to false. The metadata says it has my column from the data coming back. Quote
Tim Field Posted September 1, 2005 Author Posted September 1, 2005 Sorry it was me being useless! Returning 2 datasets, the first one being empty durrrrrr... Quote
Administrators PlausiblyDamp Posted September 1, 2005 Administrators Posted September 1, 2005 I just noticed you are using both a DataAdapter and a DataReader in your original code - if you are wanting to loop with a DataReader then I would try to remove the DataAdapter related code and see if that clears up the problem. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.