3
Answers

Problem Reading Data

ToBe

ToBe

11y
1k
1

HI Im getting an arroe when reaching :

dr = cmd.ExecuteReader();

I can't now wht is the problem 

this my code in the btnSAVE:

            cmd = new SqlCommand("sp_Main_Information", con);

 

            cmd.CommandType = CommandType.StoredProcedure;

 

            cmd.Parameters.AddWithValue("@REG_Date", dt);

            cmd.Parameters.AddWithValue("@NAME", name);

            cmd.Parameters.AddWithValue("@ADDRESS", Address);

            cmd.Parameters.AddWithValue("@YEAR", Year);

            cmd.Parameters.AddWithValue("@CURRENT_GPA ", gpa);

            cmd.Parameters.AddWithValue("@ATTCH_ID1", img1);

            cmd.Parameters.AddWithValue("@ATTCH_ID2 , img2);

            cmd.Parameters.AddWithValue("@REMARKS", remarks.Text);

 

            dr = cmd.ExecuteReader();

            dr.Read();

 

                int xx = int.Parse(dr[0].ToString());

                Response.Write(xx);

 

                    for (i = 0; i < chktype.Items.Count; i++)

                    {

                        if (chktype.Items[i].Selected == true)

                        {

                            cmd = new SqlCommand();

                            cmd.CommandText = "insert into tblItemstb values ('" + chktype.Items[i].Text + "'," + xx + ")";

                            cmd.Connection = con;

                            cmd.ExecuteNonQuery();

                        }

 

                    }

 

            dr.Close();

            cmd.ExecuteNonQuery();

 

            dr = cmd.ExecuteReader();

            dr.Read();

 

                int yy = int.Parse(dr[0].ToString());

                Response.Write(yy);

 

                    for (i = 0; i < chkoption.Items.Count; i++)

                    {

                        if (chkoption.Items[i].Selected == true)

                        {

                            cmd = new SqlCommand();

                            cmd.CommandText = "insert into tbloptions values ('" + chkoption.Items[i].Text + "'," + yy + ")";

                            cmd.Connection = con;

                            cmd.ExecuteNonQuery();

                        }

 

                    }

 

            dr.Close();

            cmd.ExecuteNonQuery();

 

            con.Close();

            lbldone.Text = "Record Added Successfully!";

 

        }

 

    }

 



Answers (3)
Next Recommended Forum