MDB to CDB Copy/Convert issue

Last post 07-22-2004 15:10 by Anonymous. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 07-20-2004 18:52

    MDB to CDB Copy/Convert issue

    I have created an app to Copy and Convert my MDB file to CDB on the pocketpc. I currently have it able to transfer 2 databases that my company use on the device. One database can range from a few MB to a few hundred, while the other wont max over 500k in size. After transferring the larger MDB file(successfully), I can't transfer the smaller file succesfully.

    heres the code for the btnCopy_Click event

    private void btnCopy_Click(object sender, System.EventArgs e)
    {
    try
    {
    Thread sendThread = new Thread (new ThreadStart(SendToDevice));
    sendThread.Start();
    timer1.Enabled = true;
    }
    catch (Exception ex)
    {
    MessageBox.Show(ex.Message);
    }
    }


    and this is the SendToDevice code:

    private void SendToDevice()
    {
    StringBuilder sbFileName1 = new StringBuilder("db1.cdb");
    StringBuilder sbFileName2 = new StringBuilder("db2.cdb");
    StringBuilder sbFileName = new StringBuilder();


    try
    {
    if(!m_rapi.Connected)
    {
    button1_Click(null, null); //disconnect
    throw new Exception("Not Connected. You must be connected to transfer a file to the device.");
    }
    switch (cmbFastSelect.SelectedIndex)
    {
    case 0:
    sbTables.Append(sbDb1Tables.ToString());
    sbFileName.Append(sbFileName1.ToString());
    break;
    case 1:
    sbTables.Append(sbDb2Tables.ToString());
    sbFileName.Append(sbFileName2.ToString());
    break;

    }
    lblTransfer.Text = "Transferring...";
    int nStatus = -1; // Status of connection
    if(m_rapi.DeviceFileExists(txtDestination.Text))
    {
    m_rapi.DeleteDeviceFile(txtDestination.Text);
    }
    if(m_rapi.DeviceFileExists(txtDestination.Text))
    {
    throw new Exception("File not deleted succesfully.");
    }
    else
    {
    nStatus = AdoceSync.DesktopToDevice(
    txtSource.Text, // Source database (.mdb)
    sbTables.ToString(), // tables from db to convert
    false, // Sync with Activesync?
    true, // Overwrite?
    txtDestination.Text // Destination database (.cdb)
    );
    }
    switch (nStatus)
    {
    case 0:
    disconnect.Enabled = true;
    lblTransfer.Text = "Transfer Complete";
    DialogResult dlgResult = new DialogResult();
    dlgResult = MessageBox.Show("Finished transferring "+txtSource.Text+"\nDisconnect from device?(This will NOT disconnect ActiveSync)\n\nClick 'No' if you wish to transfer another database.","Disconnect from device?",MessageBoxButtons.YesNo,MessageBoxIcon.Question);
    if(dlgResult.ToString() == "Yes")
    {
    button1_Click(null, null);
    }
    break;
    case -2147024894:
    MessageBox.Show("Device is not connected.");
    break;
    case -2146824447:
    MessageBox.Show("Destination table already exists.");
    break;
    case -2147217865:
    MessageBox.Show("Table doesn't exist on device.");
    break;
    default:
    MessageBox.Show("An error occurred transferring the data.");
    break;
    }

    }
    catch (Exception ex)
    {
    MessageBox.Show("Error: " + ex.Message+"\n"+ex.TargetSite.ToString(),ex.Source.ToString());
    lblTransfer.Text = "Transfer Failed";
    }
    }


    I was thinking maybe my threads are messed up or something, i put the connection/transfer related stuff on threads outside the UI so users could still navigate to the help file.

    So simply, after transferring the larger MDB, the smaller MDB gets created as a CDB on the device, but does not completely transfer.
    and that only happens after transfering the larger MDB. However i can transfer the larger one again and again with no problem. Oh and I am using the ConnectAsync function.

    any help will be greatly appreciated.
  • 07-20-2004 18:56 In reply to

    Re: MDB to CDB Copy/Convert issue

    this actually belongs in the OpenNETCF.Desktop.Communications forum i beleive, sorry bout that.
  • 07-22-2004 15:10 In reply to

    Re: MDB to CDB Copy/Convert issue

    i realized that i wasnt specifying ALL the tables i wanted for the smaller db, after specifying them the transfers seem to work, just thought someone else might be interested to know that it would be my recommendation to always specify the table names when transferring MDB to CDB

    cheers! :-)
Page 1 of 1 (3 items)