Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 117973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:25:16+00:00 2026-05-11T03:25:16+00:00

I’ve been working on my issue for 30 hours. Each time I fix one

  • 0

I’ve been working on my issue for 30 hours. Each time I fix one thing a new error arises. All I want to do is take a DataTables from memory and simply update an Access .MDB file. Here is my code:

using System; using System.Collections.Generic; using System.Data; using System.Data.OleDb; using System.IO; using System.Linq; using System.Text;  namespace LCR_ShepherdStaffupdater_1._0 {     public class DatabaseHandling     {         static DataTable datatableB = new DataTable();         static DataTable datatableA = new DataTable();         public static DataSet datasetA = new DataSet();         public static DataSet datasetB = new DataSet();         static OleDbDataAdapter adapterA = new OleDbDataAdapter();         static OleDbDataAdapter adapterB = new OleDbDataAdapter();         static string connectionstringA = 'Provider=Microsoft.Jet.OLEDB.4.0;' + 'Data Source=' + Settings.getfilelocationA();         static string connectionstringB = 'Provider=Microsoft.Jet.OLEDB.4.0;' + 'Data Source=' + Settings.getfilelocationB();         static OleDbConnection dataconnectionB = new OleDbConnection(connectionstringB);         static OleDbConnection dataconnectionA = new OleDbConnection(connectionstringA);         static DataTable tableListA;         static DataTable tableListB;          static public void addTableA(string table, bool addtoDataSet)         {             dataconnectionA.Open();             datatableA = new DataTable(table);             try             {                 OleDbCommand commandselectA = new OleDbCommand('SELECT * FROM [' + table + ']', dataconnectionA);                 adapterA.SelectCommand = commandselectA;                 adapterA.Fill(datatableA);             }             catch             {                 Logging.updateLog('Error: Tried to get ' + table + ' from DataSetA. Table doesn't exist!', true, false, false);             }              if (addtoDataSet == true)             {                 datasetA.Tables.Add(datatableA);                 Logging.updateLog('Added DataTableA: ' + datatableA.TableName.ToString() + ' Successfully!', false, false, false);             }              dataconnectionA.Close();         }          static public void addTableB(string table, bool addtoDataSet)         {             dataconnectionB.Open();             datatableB = new DataTable(table);              try             {                 OleDbCommand commandselectB = new OleDbCommand('SELECT * FROM [' + table + ']', dataconnectionB);                 adapterB.SelectCommand = commandselectB;                 adapterB.Fill(datatableB);             }             catch             {                 Logging.updateLog('Error: Tried to get ' + table + ' from DataSetB. Table doesn't exist!', true, false, false);             }                if (addtoDataSet == true)             {                 datasetB.Tables.Add(datatableB);                 Logging.updateLog('Added DataTableB: ' + datatableB.TableName.ToString() + ' Successfully!', false, false, false);             }              dataconnectionB.Close();         }          static public string[] getTablesA(string connectionString)         {             dataconnectionA.Open();             tableListA = dataconnectionA.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new Object[] { null, null, null, 'TABLE' });             string[] stringTableListA = new string[tableListA.Rows.Count];              for (int i = 0; i < tableListA.Rows.Count; i++)             {                 stringTableListA[i] = tableListA.Rows[i].ItemArray[2].ToString();             }             dataconnectionA.Close();             return stringTableListA;         }          static public string[] getTablesB(string connectionString)         {             dataconnectionB.Open();             tableListB = dataconnectionB.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new Object[] { null, null, null, 'TABLE' });             string[] stringTableListB = new string[tableListB.Rows.Count];              for (int i = 0; i < tableListB.Rows.Count; i++)             {                 stringTableListB[i] = tableListB.Rows[i].ItemArray[2].ToString();             }             dataconnectionB.Close();             return stringTableListB;         }          static public void createDataSet()         {              string[] tempA = getTablesA(connectionstringA);             string[] tempB = getTablesB(connectionstringB);             int percentage = 0;             int maximum = (tempA.Length + tempB.Length);              Logging.updateNotice('Loading Tables...');             Logging.updateLog('Started Loading File A', false, false, true);             for (int i = 0; i < tempA.Length ; i++)             {                 if (!datasetA.Tables.Contains(tempA[i]))                 {                     addTableA(tempA[i], true);                     percentage++;                     Logging.loadStatus(percentage, maximum);                 }                 else                 {                     datasetA.Tables.Remove(tempA[i]);                     addTableA(tempA[i], true);                     percentage++;                     Logging.loadStatus(percentage, maximum);                 }             }             Logging.updateLog('Finished loading File A', false, false, true);             Logging.updateLog('Started loading File B', false, false, true);             for (int i = 0; i < tempB.Length ; i++)             {                 if (!datasetB.Tables.Contains(tempB[i]))                 {                     addTableB(tempB[i], true);                     percentage++;                     Logging.loadStatus(percentage, maximum);                 }                 else                 {                     datasetB.Tables.Remove(tempB[i]);                     addTableB(tempB[i], true);                     percentage++;                     Logging.loadStatus(percentage, maximum);                 }             }             Logging.updateLog('Finished loading File B', false, false, true);             Logging.updateLog('Both files loaded into memory successfully', false, true, false);           }          static public DataTable getDataTableA()         {             datatableA = datasetA.Tables[Settings.textA];              return datatableA;         }         static public DataTable getDataTableB()         {             datatableB = datasetB.Tables[Settings.textB];             return datatableB;         }          static public DataSet getDataSetA()         {             return datasetA;         }          static public DataSet getDataSetB()         {             return datasetB;         }          static public void InitiateCopyProcessA()         {             DataSet tablesA;             tablesA = DatabaseHandling.getDataSetA();                  foreach (DataTable table in tablesA.Tables)                 {                     OverwriteTable(table, table.TableName);                     Logging.updateLog('Copied ' + table.TableName + ' successfully.', false, true, false);                 }          }          static void OverwriteTable(DataTable sourceTable, string tableName)         {             using (var destConn = new OleDbConnection(connectionstringA))             using (var destCmd = new OleDbCommand(tableName, destConn) { CommandType = CommandType.TableDirect })             using (var destDA = new OleDbDataAdapter(destCmd))             {                 // Since we're using a single table, we can have the CommandBuilder                 // generate the appropriate INSERT and DELETE SQL statements                 using (var destCmdB = new OleDbCommandBuilder(destDA))                 {                     destCmdB.QuotePrefix = '['; // quote reserved column names                     destCmdB.QuoteSuffix = ']';                     destDA.DeleteCommand = destCmdB.GetDeleteCommand();                     destDA.InsertCommand = destCmdB.GetInsertCommand();                      // Get rows from destination, and delete them                     var destTable = new DataTable();                     destDA.Fill(destTable);                     foreach (DataRow dr in destTable.Rows)                     {                         dr.Delete();                     }                       destDA.Update(destTable); // !!! Run-time error: Syntax error in FROM clause. !!!                      // Set rows from source as Added, so the DataAdapter will insert them                     foreach (DataRow dr in sourceTable.Rows)                     {                         dr.SetAdded();                     }                     destDA.Update(sourceTable);                 }             }         }            }               } 

EDIT:

OKAY THANK YOU! But like-wise a new problem arose. Same source code, but as I was copying tables to the .MDB file, 10 or so tables had already been copied then I get this run-time error:

Dynamic SQL generation for the DeleteCommand is not supported against a SelectCommand that does not return any key column information.

On this command destDA.DeleteCommand = destCmdB.GetDeleteCommand();

This should be my last problem and my project will be complete.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T03:25:16+00:00Added an answer on May 11, 2026 at 3:25 am
    destCmdB.QuotePrefix = '['; // quote reserved column names destCmdB.QuotePrefix = ']'; 

    QuotePrefix twice? Perhaps that could be an issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 165k
  • Answers 165k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Categories extend the original class, but they don't subclass it,… May 12, 2026 at 12:54 pm
  • Editorial Team
    Editorial Team added an answer Haven't tested this, but it's something like: RewriteRule \.php$ -… May 12, 2026 at 12:54 pm
  • Editorial Team
    Editorial Team added an answer "0:0:0:0:0:0:0:1" is the IPv6 loopback address as defined in RFC… May 12, 2026 at 12:54 pm

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.