public void loadCourses() { DBConnect objDB = new DBConnect(); SqlCommand objCommand = new SqlCommand(); objCommand.CommandType = CommandType.StoredProcedure; objCommand.CommandText = "ShowAllCourses"; DataSet myDS = objDB.GetDataSetUsingCmdObj(objCommand); gvCourses.DataSource = myDS; gvCourses.DataBind(); }
public DataSet GetAccounts() { DBConnect objdb = new DBConnect(); SqlCommand sqlCommand = new SqlCommand(); sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.CommandText = "GetAllAccounts"; DataSet dataset = objdb.GetDataSetUsingCmdObj(sqlCommand); return dataset; }
public decimal getAccountBalance(string name, float cardNumber) { DBConnect objdb = new DBConnect(); SqlCommand sqlCommand = new SqlCommand(); sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.CommandText = "GetAccountBalance"; sqlCommand.Parameters.AddWithValue("@Name", name); sqlCommand.Parameters.AddWithValue("@CardNumber", cardNumber); SqlParameter returnParameter = new SqlParameter("@Balance", DbType.Decimal); returnParameter.Direction = ParameterDirection.ReturnValue; sqlCommand.Parameters.Add(returnParameter); // Execute stored procedure using DBConnect object and the SQLCommand object objdb.GetDataSetUsingCmdObj(sqlCommand); decimal balance; balance = decimal.Parse(sqlCommand.Parameters["@Balance"].Value.ToString()); return balance; }
public int getCreditCardCount() { DBConnect objdb = new DBConnect(); SqlCommand sqlCommand = new SqlCommand(); sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.CommandText = "GetCreditCardCount"; //stores the value in the variable @theCount SqlParameter returnParameter = new SqlParameter("@theCount", DbType.Int32); returnParameter.Direction = ParameterDirection.ReturnValue; sqlCommand.Parameters.Add(returnParameter); // Execute stored procedure using DBConnect object and the SQLCommand object objdb.GetDataSetUsingCmdObj(sqlCommand); int count; count = int.Parse(sqlCommand.Parameters["@theCount"].Value.ToString()); return count; }
public DataSet getAllTransactions() { //Update Account balance using stored procedure DBConnect objdb = new DBConnect(); SqlCommand sqlCommand = new SqlCommand(); sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.CommandText = "GetAllTransactions"; DataSet dataset = objdb.GetDataSetUsingCmdObj(sqlCommand); return dataset; }
protected void gvCourses_RowDeleting(object sender, GridViewDeleteEventArgs e) { int rowIndex = e.RowIndex; int selectedCRN = int.Parse(gvCourses.Rows[rowIndex].Cells[1].Text); DBConnect objDB = new DBConnect(); SqlCommand objCommand = new SqlCommand(); objCommand.CommandType = CommandType.StoredProcedure; objCommand.CommandText = "DeleteCourse"; objCommand.Parameters.AddWithValue("@CRN", selectedCRN); objDB.GetDataSetUsingCmdObj(objCommand); objDB.DoUpdateUsingCmdObj(objCommand); loadCourses(); }