0

I am loading data from an excel sheet into a SQL table and then joining that data to another table with a script. On Page Load of my program I would like to delete all rows from my "temp" table. I am currently doing this, but it is not working at all. By not working I mean nothing happens. No errors, but also it does not delete anything from my table. I set a breakpoint on the if and it doesnt even hit the break point.

 protected void Page_Load(object sender, EventArgs e)
    {
      if (!IsPostBack)
        {
            SqlConnection sqlConn1;
            String strConnString1 = ConfigurationManager.ConnectionStrings["MyConnection"].ToString();
            sqlConn1 = new SqlConnection(strConnString1);

            string cleartQuery = "Truncate Table [My Table]";
            SqlCommand sqlCmdSelect = new SqlCommand(cleartQuery, sqlConn1);
            sqlCmdSelect.Connection.Open();
            sqlCmdSelect.ExecuteNonQuery();
            sqlCmdSelect.Connection.Close();
        }
     }
codeFinatic
  • 171
  • 1
  • 5
  • 18

0 Answers0