Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //!=======================================
- //!GETS ALL RECORDS FROM DATABASE==WORKING
- //!=======================================
- BindingSource binder = new BindingSource();
- private void btnGetAll_Click(object sender, EventArgs e)
- {
- string conString;
- conString = Properties.Settings.Default.jobsConnectionString;
- SqlConnection con;
- con = new SqlConnection(conString);
- con.Open();
- SqlCommand cmd;
- cmd = new SqlCommand("AllRecords", con);
- SqlDataAdapter adaptor;
- adaptor = new SqlDataAdapter(cmd);
- DataTable dataTable;
- dataTable = new DataTable();
- adaptor.Fill(dataTable);
- dataGridView1.DataSource = binder;
- binder.DataSource = dataTable;
- con.Close();
- }
- //!=========================================================
- //!ATTEMPT TO GET STORED PROCEDURE TO DISPLAY INTO A TEXTBOX
- //!=========================================================
- private void button1_Click(object sender, EventArgs e)
- {
- string conString;
- conString = Properties.Settings.Default.jobsConnectionString;
- SqlConnection con;
- con = new SqlConnection(conString);
- con.Open();
- SqlCommand cmd;
- cmd = new SqlCommand("SumTest", con);
- SqlDataAdapter adaptor;
- adaptor = new SqlDataAdapter(cmd);
- SqlDataReader reader;
- reader = cmd.ExecuteReader();
- while (reader.Read())
- {
- textBox1.Text = reader["SumTest"].ToString();
- }
- con.Close();
- }
- RETURNS ERROR: System.IndexOutOfRangeException: 'SumTest'
Add Comment
Please, Sign In to add comment