public void DbDelete(DbConnection myDbCon) { string sqlCommand = "DELETE FROM MOVIE_SITECONTENTS "; sqlCommand += "WHERE ID = @pId "; MovieFileContentsParent parent = new MovieFileContentsParent(); SqlCommand command = new SqlCommand(); command = new SqlCommand(sqlCommand, myDbCon.getSqlConnection()); SqlParameter[] sqlparams = new SqlParameter[1]; sqlparams[0] = new SqlParameter("@pId", SqlDbType.Int); sqlparams[0].Value = Id; myDbCon.SetParameter(sqlparams); myDbCon.execSqlCommand(sqlCommand); }
public void DbUpdate(DbConnection myDbCon) { string sqlCommand = "UPDATE MOVIE_SITECONTENTS "; sqlCommand += "SET SITE_NAME = @pSiteName, NAME = @pName, PARENT_PATH = @pParentPath, MOVIE_NEWDATE = @pMovieNewDate, MOVIE_COUNT = @pMovieCount, PHOTO_COUNT = @pPhotoCount, EXTENSION = @pExtension "; sqlCommand += "WHERE ID = @pId "; MovieFileContentsParent parent = new MovieFileContentsParent(); SqlCommand command = new SqlCommand(); command = new SqlCommand(sqlCommand, myDbCon.getSqlConnection()); SqlParameter[] sqlparams = new SqlParameter[8]; // Create and append the parameters for the Update command. sqlparams[0] = new SqlParameter("@pSiteName", SqlDbType.VarChar); sqlparams[0].Value = SiteName; sqlparams[1] = new SqlParameter("@pName", SqlDbType.VarChar); sqlparams[1].Value = Name; sqlparams[2] = new SqlParameter("@pParentPath", SqlDbType.VarChar); sqlparams[2].Value = ParentPath; sqlparams[3] = new SqlParameter("@pMovieNewDate", SqlDbType.DateTime); if (MovieNewDate.Year >= 2000) sqlparams[3].Value = MovieNewDate; else sqlparams[3].Value = Convert.DBNull; sqlparams[4] = new SqlParameter("@pMovieCount", SqlDbType.VarChar); sqlparams[4].Value = MovieCount; // sqlparams[4] = new SqlParameter("@pSellDate", SqlDbType.DateTime); // if (data.SellDate.Year >= 2000) // sqlparams[4].Value = data.SellDate; // else // sqlparams[4].Value = Convert.DBNull; sqlparams[5] = new SqlParameter("@pPhotoCount", SqlDbType.VarChar); sqlparams[5].Value = PhotoCount; sqlparams[6] = new SqlParameter("@pExtension", SqlDbType.VarChar); sqlparams[6].Value = Extension; sqlparams[7] = new SqlParameter("@pId", SqlDbType.Int); sqlparams[7].Value = Id; myDbCon.SetParameter(sqlparams); myDbCon.execSqlCommand(sqlCommand); }