"sb.Append(((int)rdr[mod_int]));"
"index was outside the bound of an array"
public static void dispaly_functions_module_role(string proc_fun, int mod_int, int rol_int, CheckedListBox c1) { try { int count = 0; int count1 = 0; string sql_string = ("Data Source=sdggdfgdfgdfg;Initial Catalog=GCERP_SEC;User Id=sdfgdsfg;Password=fgsdfg"); SqlConnection conn = new SqlConnection(sql_string); SqlCommand command = new SqlCommand(proc_fun, conn); conn.Open(); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@mid", mod_int); command.Parameters.AddWithValue("@rid", rol_int); SqlDataReader rdr = command.ExecuteReader(); if (rdr.HasRows) { StringBuilder sb = new StringBuilder(); string a; while (rdr.Read()) { sb.Append(((int)rdr[mod_int])); sb.Append(((int)rdr[rol_int])); sb.Append("\n"); a = sb.ToString().Trim(); c1.Items.Add(a); // Items.Insert(count1, a); sb.Length = 0; count1++; } } else { if (count1 != 0) MessageBox.Show(" your data is saved"); else MessageBox.Show("not found"); } rdr.Close(); command.ExecuteNonQuery(); count++; conn.Close(); conn.Dispose(); } catch (Exception ex) { MessageBox.Show(ex.Message); MessageBox.Show("Error in database connection"); } }
a = sb.ToString().Trim();
StringBuilder
StringBuilder.Clear()
CheckBox
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)