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

  • SEARCH
  • Home
  • 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 3951768
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:46:13+00:00 2026-05-20T01:46:13+00:00

I am unit/auto-testing a large application which uses MSFT Sql Server, Oracle as well

  • 0

I am unit/auto-testing a large application which uses MSFT Sql Server, Oracle as well as Sybase as its back end. Maybe there are better ways to interface with a db, but ODBC library is what I have to use. Given these constraints, there is something that I need to figure out, and I would love your help on this. My tests do change the state of the database, and I seek an inexpensive, 99.99% robust way to restore things after I am done ( I feel like a full db restore after each test is too much of a penalty). So, I seek a complement to this function below – I need a way to populate a table from a DataSet.

    private DataSet ReadFromTable(ODBCConnection connection, string tableName)
    {
        string selectQueryString = String.Format("select * from {0};", tableName);
        DataSet dataSet = new DataSet();
        using (OdbcCommand command = new OdbcCommand(selectQueryString, connection))
        using (OdbcDataAdapter odbcAdapter = new OdbcDataAdapter(command))
        {
            odbcAdapter.Fill(dataSet);
        }

        return dataSet;
    }

    // The method that I seek.
    private void WriteToTable(ODBCConnection connection, string tableName, DataSet data)
    {
        ...
    }

I realize that things can be more complicated – that there are triggers, that some tables depend on others. However, we barely use any constraints for the sake of efficiency of the application under test. I am giving you this information, so that perhaps you have a suggestion on how to do things better/differently. I am open to different approaches, as long as they work well.

The non-negotiables are: MsTest library, VS2010, C#, ODBC Library, support for all 3 vendors.

  • 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. Editorial Team
    Editorial Team
    2026-05-20T01:46:13+00:00Added an answer on May 20, 2026 at 1:46 am

    Is this what you mean? I might be overlooking something

    In ReadFromTable

    dataset.WriteXmlSchema(memorySchemaStream);
    dataset.WriteXml(memoryDataStream);
    

    In WriteToTable

    /*  empty the table first */
    
    Dataset template = new DataSet();
    template.ReadXmlSchema(memorySchemaStream);
    template.ReadXml(memoryDataStream);
    
    Dataset actual = new DataSet();
    actual.ReadXmlSchema(memorySchemaStream);
    
    actual.Merge(template, false);
    
    actual.Update();
    

    Other variant might be: read the current data, do compare with template and based on what you are missing add the data to the actual dataset. The only thing to remember is that you cannot copy the actual DataRows from one dataset to another, you have to recreate DataRows

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

Sidebar

Related Questions

I'm unit testing a method which uses automapper to map a class from my
We have started using the boost unit testing library for a large existing code
Possible Duplicate: Auto-generation of .NET unit tests I am pretty new to Unit Testing
What is the best, preferably free/open source tool for auto-generating Java unit-tests? I know,
Unit testing and ASP.NET web applications are an ambiguous point in my group. More
Unit testing is, roughly speaking, testing bits of your code in isolation with test
Unit testing sounds great to me, but I'm not sure I should spend any
Unit testing with C/C++: What do you teach people who either did not do
I've heard that unit testing is totally awesome, really cool and all manner of
Does Python have a unit testing framework compatible with the standard xUnit style of

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.