Hi,
I want to use sqldatareader within another reader.there is no error.but stored procedure didnt work.
here my code
private string GetStatus(string bearertoken) { string sqlDataSource = _configuration.GetConnectionString("ConnStr"); SqlConnection con = new SqlConnection(sqlDataSource); con.Open(); SqlCommand cmd = new SqlCommand(query, con); SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read()) { var id = reader["id"].ToString(); if (status == "SUCCESS") { DataTable table = new DataTable(); SqlDataReader myReader; string sqlDataSource = _configuration.GetConnectionString("ConnStr"); SqlConnection sql = new SqlConnection(sqlDataSource); sql.Open(); SqlCommand scCommand = new SqlCommand("SP_UpdateStatus", sql); scCommand.CommandType = CommandType.StoredProcedure;
scCommand.Parameters.Add("@Id", SqlDbType.VarChar, 50).Value = id; myReader = scCommand.ExecuteReader(); table.Load(myReader); myReader.Close(); } } } } } } reader.Close(); con.Close(); return "Ok"; }