none
Problem with data base update after work with dataSet RRS feed

  • Question

  • Hi every body, i have a problem with dataset i just want to create a new table in my data set, after that i want to update my data base ,after executing the code i can not found the new table "Suppliers" in the database, so the data base is not updated, This is my code:
    public static void dataSetCreationNouvelleDataTableSuppliers(SqlConnection oConnection)
        {
          try
          {
            oConnection.Open();
    
            //DataSet ds = new DataSet("SuppliersProducts");
            DataTable SuppliersTable = new DataTable("Suppliers");
            DataColumn col = new DataColumn();
            col.DataType = typeof(System.Int64);
            col.ColumnName = "SupplierID";
            col.ReadOnly = true;
            col.Unique = true; // values must be unique
            col.AutoIncrement = true; // keys are assigned automatically
            col.AutoIncrementSeed = -1; // first key starts with -1
            col.AutoIncrementStep = -1; // next key = prev. key - 1
            
            // Define column "ID" and set properties
            SuppliersTable.Columns.Add(col);
            SuppliersTable.PrimaryKey = new DataColumn[] { col };
            
            
            //Define and add column "CompanyName"
           col = new DataColumn();
           col.DataType = typeof(string);
           col.ColumnName = "CompanyName";
           col.ReadOnly = false;
           col.Unique = false;
           SuppliersTable.Columns.Add(col);
           ds.Tables.Add(SuppliersTable);
           ds.AcceptChanges();//
          
          }
          catch (Exception e) { Console.WriteLine("L'erreur suivante a été rencontrée :" + e.Message); }
        }
    

    I think that "ds.AcceptChanges();" will update my data base .But this method does nothing fo me

    Help PLEASE,

    Thank you in advance


    .NET forever
    Sunday, October 3, 2010 6:58 AM