Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Btrieve > Re: Updating a ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 4 Topic 937 of 1014
Post > Topic >>

Re: Updating a P.SQL DataSet

by mitzoe@[EMAIL PROTECTED] Jun 18, 2007 at 07:52 AM

I'm using P.SQL because of its btrieve-ness.  It will read the old
data files fine, but the problem is they're spread across hundreds of
folders.  The previous system saved each company's information in it's
own folder, so for Entity A, folder A has a data file for its profile,
customers, etc.  Entity B's folder has the same data file name, with
their own information, and so on.  All of the entities are owned by a
single company, and I need to get all these disseparate records into
single tables.

Each data file for a given filename is identical, so I'm able to
quickly create the array of files, loop through and read records into
the dataset.

Instead, I could open each data file individually, copy the data, and
paste it to the final table, but because there are thousands of data
files, I was hoping it would be easier and faster to write a quick-and-
dirty app to do it for me.

Here's the pertinate code:

string sql = "select * from \"" + tablename + "\"";

DataSet ds = new DataSet();
OleDbConnection con = new OleDbConnection( ConnectionString );
OleDbCommand cmd = new OleDbCommand( sql, con );

OleDbDataAdapter da = new OleDbDataAdapter( cmd );
da.SelectCommand = new OleDbCommand( sql, con );

OleDbCommandBuilder cb = new OleDbCommandBuilder( da );

foreach( string file in DataFiles ) {
    //copy the data file to data folder
    if( !CopyFile( DataFiles[count], targetFile ) ) return;

    try {
        con.Open();
        da.Fill( ds );
    } catch( OleDbException err ) {
        ErrBox( err.Message, err.ErrorCode, err.TargetSite );
    }
}

try {
    ds.AcceptChanges();
    da.Update();
} catch( OleDbException err ) {
    ErrBox( err.Message, err.ErrorCode, err.TargetSite );
} finally {
    con.Close();
}

cmd.Dispose();
con.Dispose();
da.Dispose();
ds.Dispose();

Any insight is appreciated.  Thanks.

On Jun 18, 8:04 am, "Bill Bach" <golds...@[EMAIL PROTECTED]
> wrote:
> I suspect that you have an ADO problem, and posting your code would
> probably be the best next step.
>
> However, since PSQLv9 includesBtrievev9, why are you doing a
> conversion?  The new engine should be able to read the old data files
> just fine, if you have data dictionary files for them.  (Of course,
> without DDF's, there is no ADO access, so you must have the.)  Are you
> just updating the app from an old language to ADO.NET?
>         Goldstar Software Inc.
>         Pervasive-based Products, Training & Services
>         Bill Bach
>         BillB...@[EMAIL PROTECTED]
>        http://www.goldstarsoftware.com
>         *** Chicago: Pervasive Service & Sup****t Class - 07/2007 ***
>
>
>
> mit...@[EMAIL PROTECTED]
 wrote:
> > I apologize for any inappropriate cross-posting, but wasn't sure where
> > whether this is a Pervasive or ADO.NET issue.
>
> > I'm trying to migrate data from a propietary system that's based on
> >btrieveinto Pervasive SQL 9.5 using a .NET application written in
> > C#.  The main problem is that the existing system stores its data in
> > separate folders and files, so I'm having to read each file and copy
> > its data to its corresponding P.SQL table.
>
> > There are hundreds of folders, so doing this by hand is not feasible,
> > thus my little application.
>
> > What I've done is create an array of the files appropriate to each
> > table, iterate and copy each file into the P.SQL data folder, query
> > the table, and put into a DataSet using the Fill method, appending to
> > the records already there.
>
> > So at this point I have a DataSet of all the records.  I'm leaving the
> > last file copied for that table and trying to use the DataAdapter's
> > Update method to move the DataSet into P.SQL, but when I do so nothing
> > happens.  No error, but when I query the table in P.SQL, it's still
> > just the single record that resides in that last data file.
>
> > I suspect the problem is that I'm using repeated Fill calls, but I'm
> > not sure.  I've tried the DataSet's AcceptChanges method before
> > calling Update, but no dice.  I'm new to ADO.NET's DataSet and
> > DataAdapter objects, so any help would be appreciated.
>
> > Thanks in advance.
>
> > MichaelItzoe
> > mit...@[EMAIL PROTECTED]
 Hide quoted text -
>
> - Show quoted text -
 




 4 Posts in Topic:
Updating a P.SQL DataSet
mitzoe@[EMAIL PROTECTED]   2007-06-15 13:55:04 
Re: Updating a P.SQL DataSet
"Bill Bach" <  2007-06-18 08:04:27 
Re: Updating a P.SQL DataSet
mitzoe@[EMAIL PROTECTED]   2007-06-18 07:52:23 
Re: Updating a P.SQL DataSet
mitzoe@[EMAIL PROTECTED]   2007-06-18 07:57:14 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Aug 21 18:51:24 CDT 2008.