Click here to Skip to main content
15,903,854 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
here is my code problem is it not executing after "SqlDataReader rdr = command.ExecuteReader();"
whats the problem over there can u help me
sql_string = ("Data Source=000.000.000.000;Initial Catalog=GCERP_SEC;User Id=sa;Password=kamikami;");
                SqlConnection conn = new SqlConnection(sql_string);
                SqlCommand command = new SqlCommand(str_querry, conn);
                
                conn.Open();
               
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@string1" ,SecurityModule.userName_AD);
                command.Parameters.AddWithValue("@string2", SecurityModule.moduleid);
               // SqlDataReader rdr =StoredProcedureCommand.ExecuteReader();
                
               SqlDataReader rdr = command.ExecuteReader();
              
                if (rdr.HasRows)
                {
                    StringBuilder sb = new StringBuilder();
                    string a;
                    while (rdr.Read())
                    {
                        sb.Append(((int)rdr["fnid_int"]).ToString());
                        sb.Append("\n");
                        a = sb.ToString();
                        function_name(a);
                        sb.Length = 0;
                     }                   
                        
                }
                else
                {
                    MessageBox.Show("not found");
                }
                rdr.Close();
                command.ExecuteNonQuery();
                count++;
                conn.Close();
                conn.Dispose();

            }
            catch (Exception)
            {
                MessageBox.Show("Error in database connection");
            }
        }
Posted
Updated 6-Jul-11 0:26am
v2
Comments
[no name] 6-Jul-11 6:25am    
please give us the complete code
Toniyo Jackson 6-Jul-11 6:27am    
What is the error you are getting?
kami124 6-Jul-11 6:29am    
SqlDataReader rdr = command.ExecuteReader();
till here its working and then after exception message
[no name] 6-Jul-11 6:33am    
what exception you are getting?
uttam2010 6-Jul-11 6:34am    
make sure that your store procedure have parameters @string1,@string2 or not and also check that datatype are correct.

Check your stored procedure - is it returning anything? Try executing it in the SQL Server Management studio, and check your results.
 
Share this answer
 
Comments
kami124 6-Jul-11 6:37am    
ya you are right problem is in my SQL, thanks
[no name] 6-Jul-11 6:42am    
Nice one....
Where did you mention your stored procedure's name?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900