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 8344699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:27:12+00:00 2026-06-09T06:27:12+00:00

I have a ms sql 2012 server and I use this function to add/records:

  • 0

I have a ms sql 2012 server and I use this function to add/records:

static String conString = "Provider=SQLOLEDB;Data Source = " + ecommerceServer + "; Initial Catalog = " + eCommercedbName + "; User Id = " + eCommerceUsername + "; Password = " + eCommercepassword + ";";

    public bool InsertSQL(String query, String Tablename)
    {
        OleDbConnection conn = new OleDbConnection(conString);
        try
        {
            conn.Open();
            OleDbCommand command = new OleDbCommand(query, conn);
            int count = command.ExecuteNonQuery();
            return (count > 0) ? true : false;
        }
        catch
        {
            if (conn.State.ToString() == "Open")
            {
                conn.Close();
            }
        }
        return false;
    }

The function is quite slow (for example I have similar execution for MySQL and it workd much faster. Is there any faster ways than OleDb ?

  • 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-06-09T06:27:14+00:00Added an answer on June 9, 2026 at 6:27 am

    Andrew below is an example of how you could you SQL Client as well as doing Transactions in your Query.. you can use this as a guide / learning example also replace the variables to fit your current example. also notice how I am reading my connection string from the app.config file if you do not need the Transactional code you can remove it.. but I believe it’s best to do things using transaction

     private void SomeMethod()
     {
        SqlCommand sqlcmd = new SqlCommand();
        using (SqlConnection sqlConn = new SqlConnection(ConfigurationSettings.AppSettings["strConnectionString"]))//strConnectionString
        {
           sqlConn.Open();
           sqlcmd.Connection = sqlConn;
           SqlTransaction transaction;
           // Start a local transaction.
           transaction = sqlConn.BeginTransaction("DeleteRecs");
           sqlcmd.Transaction = transaction;
           sqlcmd.CommandTimeout = 60;
           sqlcmd.CommandText = "uf_DeleteWeeks";
           sqlcmd.CommandType = System.Data.CommandType.StoredProcedure;
           try
           {
              sqlcmd.ExecuteNonQuery();
              sqlcmd.Transaction.Commit();
           }
           catch (SqlException sqle)
           {
    
            try
            {
               transaction.Rollback("DeleteRecs");
            }
            catch (Exception ex)
            {
    
            }
           Console.WriteLine(sqle.Message);
           }
          }
          ((IDisposable)sqlcmd).Dispose();
       }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SQL Server database which contains date like 2012-01-10 00:00:00.000 When I
In a SQL Server 2005 database I have a table with data logged when
I have this table named sample with these values in MS Sql Server: ID
i have this function protected function insert($data){ $data['datecreated'] = date('Y-m-d h:i:s'); echo array_keys(data) =
I have this scenario: WServer 2008, SQL Server 2005, MS Analysis services (SSAS), ISS7
In SQL Server 2012 (Denali), we have a new feature Sequence . Consider the
I have been researching, SQL Server 2012 (aka Denali) and Microsoft has a pre-release
I have SQL data that looks like this: events id name capacity 1 Cooking
I have SQL Server 2005 Report that takes a parameter in a query string
I have an SQL Server Express 2012 with the following event model in the

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.