DataAdapter and MS Access

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • elena

    DataAdapter and MS Access

    Hi, All
    Please, help
    I have .NET 1.1 and MS Access, i am reading text file into MS Access table,
    1. I did it with following statments;
    OleDbConnection conn = null;
    conn = new OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;" + "Data
    Source=C:\\Deve lopment\\WhiteP lainsDB\\Data\\ WhitePlains.mdb ;");
    conn.Open();

    OleDbCommand cmd = new OleDbCommand(sq l, conn);
    cmd.Parameters. Add("@Code", OleDbType.VarCh ar, 10).Value = @sVill;
    cmd.Parameters. Add("@TickNo", OleDbType.VarCh ar, 20).Value = @sTick;
    Where sql is "INSERT INTO..." string
    I have up to 2 million records and it takes 3 hours to accomplish this task.

    I want to try with DataSet and DataAdapter,
    DataSet ds = new DataSet();
    DataTable tb = new DataTable("Cust Table");
    tb.Columns.Add( "Code", typeof(String)) ;
    tb.Columns.Add( "TickNo", typeof(String)) ;
    ds.Tables.Add(" CustTable");
    DataRow rw;
    // read file in the loop
    i = tb.Rows.Count + 1;
    rw = tb.NewRow();
    rw["Code"] = line.Substring( 0, 1);
    rw["TickNo"] = line.Substring( 1, 10);
    // populate 39 fields...
    tb.Rows.Add(rw) ;
    // End of file

    OleDbDataAdapte r da = new OleDbDataAdapte r();
    How to insert DataSet to MS Access table?
    Or any other ideas, any links to this topic or code snipet
    (I have to use Access db ) or should i update .NET 2.0 will be better
    solution?
    Please, advise if it possible at all.


  • Cor Ligthert [MVP]

    #2
    Re: DataAdapter and MS Access

    Elena,

    SQLExpress with Net 2.0 and SQL bulkcopy will probably do a better job for
    you. The dataset is no alternative, it will only slow your proces down and
    in your present situations is in my idea the Insert the best..



    Cor

    "elena" <elena@discussi ons.microsoft.c omschreef in bericht
    news:542DA54A-FB65-48C2-AF0B-6365F7A394B7@mi crosoft.com...
    Hi, All
    Please, help
    I have .NET 1.1 and MS Access, i am reading text file into MS Access
    table,
    1. I did it with following statments;
    OleDbConnection conn = null;
    conn = new OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;" + "Data
    Source=C:\\Deve lopment\\WhiteP lainsDB\\Data\\ WhitePlains.mdb ;");
    conn.Open();
    >
    OleDbCommand cmd = new OleDbCommand(sq l, conn);
    cmd.Parameters. Add("@Code", OleDbType.VarCh ar, 10).Value = @sVill;
    cmd.Parameters. Add("@TickNo", OleDbType.VarCh ar, 20).Value = @sTick;
    Where sql is "INSERT INTO..." string
    I have up to 2 million records and it takes 3 hours to accomplish this
    task.
    >
    I want to try with DataSet and DataAdapter,
    DataSet ds = new DataSet();
    DataTable tb = new DataTable("Cust Table");
    tb.Columns.Add( "Code", typeof(String)) ;
    tb.Columns.Add( "TickNo", typeof(String)) ;
    ds.Tables.Add(" CustTable");
    DataRow rw;
    // read file in the loop
    i = tb.Rows.Count + 1;
    rw = tb.NewRow();
    rw["Code"] = line.Substring( 0, 1);
    rw["TickNo"] = line.Substring( 1, 10);
    // populate 39 fields...
    tb.Rows.Add(rw) ;
    // End of file
    >
    OleDbDataAdapte r da = new OleDbDataAdapte r();
    How to insert DataSet to MS Access table?
    Or any other ideas, any links to this topic or code snipet
    (I have to use Access db ) or should i update .NET 2.0 will be better
    solution?
    Please, advise if it possible at all.
    >
    >

    Comment

    Working...