hjran abdpor
چهارشنبه 05 اسفند 1388, 13:30 عصر
با سلام به دوستان.
یک پایگاه داده دارم که شامل 18 جدول است . از طریق dataset با انها در تعامل هستم (حذف و ویرایشو اضافه کردن را با متهدهای که خودم تعریف کردم انجام میدم البته داخل تغییرات داخل dataset انجام میشه ؟
حالا من میخوام تغییرات در جدول پایگاه داده هم اعمال بشه ؟
چکار کنم که همزمان تغییرات در دو جهت هم در دیتاسیت و هم در جدوال صورت گیرید ؟
iman_ad
چهارشنبه 05 اسفند 1388, 21:48 عصر
با دیتاست نمی شه عزیز دلم
با دیتا ادپتور می شه
(http://javascript%3cb%3e%3c/b%3E:CopyCode('ctl00_MTCS_main_ctl17_code');)
public static void BatchUpdate(DataTable dataTable,Int32 batchSize){ // Assumes GetConnectionString() returns a valid connection string. string connectionString = GetConnectionString(); // Connect to the AdventureWorks database. using (SqlConnection connection = new SqlConnection(connectionString)) { // Create a SqlDataAdapter. SqlDataAdapter adapter = new SqlDataAdapter(); // Set the UPDATE command and parameters. adapter.UpdateCommand = new SqlCommand( "UPDATE Production.ProductCategory SET " + "Name=@Name WHERE ProductCategoryID=@ProdCatID;", connection); adapter.UpdateCommand.Parameters.Add("@Name", SqlDbType.NVarChar, 50, "Name"); adapter.UpdateCommand.Parameters.Add("@ProdCatID", SqlDbType.Int, 4, "ProductCategoryID"); adapter.UpdateCommand.UpdatedRowSource = UpdateRowSource.None; // Set the INSERT command and parameter. adapter.InsertCommand = new SqlCommand( "INSERT INTO Production.ProductCategory (Name) VALUES (@Name);", connection); adapter.InsertCommand.Parameters.Add("@Name", SqlDbType.NVarChar, 50, "Name"); adapter.InsertCommand.UpdatedRowSource = UpdateRowSource.None; // Set the DELETE command and parameter. adapter.DeleteCommand = new SqlCommand( "DELETE FROM Production.ProductCategory " + "WHERE ProductCategoryID=@ProdCatID;", connection); adapter.DeleteCommand.Parameters.Add("@ProdCatID", SqlDbType.Int, 4, "ProductCategoryID"); adapter.DeleteCommand.UpdatedRowSource = UpdateRowSource.None; // Set the batch size. adapter.UpdateBatchSize = batchSize; // Execute the update. adapter.Update(dataTable); }}
hjran abdpor
پنج شنبه 06 اسفند 1388, 15:54 عصر
میشه یکم بیشتر توضیح بدین .
چکار کنم نفهمیدم؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟ ؟
vBulletin® v4.2.5, Copyright ©2000-1404, Jelsoft Enterprises Ltd.