running DB backup procedure in C# RRS feed

  • Question

  • Hi,
        I have a MS SQL stored procedure to backup a DB. i want to execute it in C#. I tried using ExecuteNonQuery, but it didnt work. here's my code:

    private bool runStoredProcedure()
                int t = 0;
                SqlConnection conn = Connection.getConnection();
                    SqlCommand cmd = new SqlCommand("dbBackup", conn);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add(new SqlParameter("@Path", @"c:\"));
                    cmd.Parameters.Add(new SqlParameter("@DBName", "Northwind"));
                    t = cmd.ExecuteNonQuery();
                catch (Exception e)


                if (t > 0)
                    return true;
                    return false;

    dbBackup is the name of the procedure. All help appreciated.

    Wednesday, September 5, 2007 7:04 AM

All replies

  • hey, it's ok. i figured out whats wrong.
    Wednesday, September 5, 2007 7:46 AM