Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. ADOX problem

ADOX problem

Scheduled Pinned Locked Moved C#
helpdatabasecomsecurityxml
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sabry1905
    wrote on last edited by
    #1

    hello all i am trying to serialize an access database into xml file then recreate the database again from the xml file, i ma using "Microsoft ADO Ext. 2.8 for DDL and Security" here is a sample code of recreating the database from the xml file. DS2 = new DataSet(); DS2.ReadXml(Application.StartupPath + @"\DataSet.xml"); DataTable temp = DS2.Tables[0]; string strConn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Application.StartupPath+@"\DataSet.mdb"; ADOX.CatalogClass cat = new CatalogClass(); cat.Create(strConn + "; Jet OLEDB:Engine Type = 5"); cat.Tables.Append((Object)temp); cat=null; but i got a com exception says "Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another". can anyone help?

    S 1 Reply Last reply
    0
    • S Sabry1905

      hello all i am trying to serialize an access database into xml file then recreate the database again from the xml file, i ma using "Microsoft ADO Ext. 2.8 for DDL and Security" here is a sample code of recreating the database from the xml file. DS2 = new DataSet(); DS2.ReadXml(Application.StartupPath + @"\DataSet.xml"); DataTable temp = DS2.Tables[0]; string strConn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Application.StartupPath+@"\DataSet.mdb"; ADOX.CatalogClass cat = new CatalogClass(); cat.Create(strConn + "; Jet OLEDB:Engine Type = 5"); cat.Tables.Append((Object)temp); cat=null; but i got a com exception says "Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another". can anyone help?

      S Offline
      S Offline
      selcuks
      wrote on last edited by
      #2

      From the code, I understand that you are trying to create table in access from the dataset but your approach is not acceptable for ADOX. In a similar task, I have tried to export my dataset to an mdb database and I had to construct SQL commands from the dataset to create and insert data. I think this one can give you a starting point. Here is my create table method:

          /// /// Constructs the required SQL Query to create the tables in mdb database and then executes the query.
          /// 
          private void CreateTables()
          {
              string sqlCommand = "CREATE TABLE ";
              foreach (DataTable dTable in currentDataSet.Tables)
              {
                  string sqlCreate = sqlCommand + dTable.TableName + "(";
                  int cnt = 0;
                  foreach (DataColumn dColumn in dTable.Columns)
                  {
                      string sqlCreateCommand = sqlCreate + dColumn.ColumnName;
                      if (cnt != dTable.Columns.Count - 1)
                      {
                          cnt++;
                          sqlCreateCommand += GetDataType(dColumn) + ", ";
                      }
      
                      if (dTable.Columns.IndexOf(dColumn) == dTable.Columns.Count - 1)
                      {
                          cnt++;
                          sqlCreateCommand += GetDataType(dColumn) + ");";
                      }
                      sqlCreate = sqlCreateCommand;
                  }
      
      
                  OleDbCommand dbCommand = new OleDbCommand(sqlCreate, (OleDbConnection)dsConnection.CurrentDbConnection);
                  dbCommand.ExecuteNonQuery();
              }
      

      Always keep the Murphy Rules in mind!

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups