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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:47:07+00:00 2026-05-23T19:47:07+00:00

I am writing my very first command script as part of a work project.

  • 0

I am writing my very first command script as part of a work project.

I have written a Visual Studio 2008 C# code that will grab data from a MS Access table then imputs the data into an Oracle table.

My issue is that the MS Access database is being populated every minute and I need and want my C# code to run every few minutes.

Because this action is so important, this code is to be run on a server that is always able to back up the database because it has the space on its memory.

I was told that the best way to handle this is to write a Windows Command Script to handle this; however, I have no experience writing scripts of any kind.

Could someone please help me out with this? Thank you.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Data.OracleClient;
using System.Data.SqlClient;
using System.IO;
using System.Data.Odbc;

namespace ConsoleApplication7
{
    class Program
    {
        static void Main(string[] args)
        {
            string connectionString = "Dsn=Gas_meter_check";

            string dayTime = "";
            string hsmt = "";
            string boft = "";
            string eaft = "";
            string j9st = "";
            string lmbt = "";
            string fbst = "";
            string fcbt = "";
            string fdwpt ="";

            string fdept = "";
            string fdbt = "";
            string ffat = "";
            string ffpt = "";
            string fdnpt = "";
            string ftdt = "";
            string fppt = "";
            string fgpt = "";

            string hsmr = "";
            string bofr = "";
            string eafr = "";
            string j9sr = "";
            string lmbr = "";
            string fbsr = "";
            string fcbr = "";
            string fdwpr = "";

            string fdepr = "";
            string fdbr = "";
            string ffar = "";
            string ffpr = "";
            string fdnpr = "";
            string ftdr = "";
            string fppr = "";
            string fgpr = "";

            string sqlins = "";
            string connString = "DSN=Gas_Reporter_proj;Uid=rouge;Pwd=steel";
            OdbcConnection conn = new OdbcConnection(connString);

            OdbcConnection DbConnection = new OdbcConnection(connectionString);
            OdbcCommand DbCommand = DbConnection.CreateCommand();
            DbConnection.Open();
            DbCommand.CommandText = "SELECT Data.[Date / Time],DATA.[Hot Strip Mill Total],Data.[Basic Oxygen Furnace Total],Data.[Electro-Arc Furnace Total],Data.[J-9 Shop Total],Data.[Levy Maintence Building Total],Data.[Ford Body Shop Total], Data.[Ford Chiller Building Total],Data.[Ford Dearborn W Plant Total],Data.[Ford Dearborn E Plant Total], Data.[Ford Dearborn Balcony Total], Data.[Ford Final Assembly Total],Data.[Ford Frame Plant Total], Data.[Ford Dearborn N Plant Total],Data.[Ford Tool and Die Total], Data.[Ford Paint Plant Total],Data.[Ford Glass Plant Total], DATA.[Hot Strip Mill Rate], Data.[Basic Oxygen Furnace Rate], Data.[Electro-Arc Furnace Rate],Data.[J-9 Shop Rate],Data.[Levy Maintence Building Rate],Data.[Ford Body Shop Rate],Data.[Ford Chiller Building Rate],Data.[Ford Dearborn W Plant Rate],Data.[Ford Dearborn E Plant Rate],Data.[Ford Dearborn Balcony Rate],Data.[Ford Final Assembly Rate],Data.[Ford Frame Plant Rate],Data.[Ford Dearborn N Plant Rate],Data.[Ford Tool and Die Rate],Data.[Ford Paint Plant Rate],Data.[Ford Glass Plant Rate]FROM DATA";         
            OdbcDataReader DbReader = DbCommand.ExecuteReader();
            int fCount = DbReader.FieldCount;
   try
  {
            OdbcCommand cmdnon = new OdbcCommand(sqlins, conn);                            
            conn.Open();

            cmdnon.Parameters.Add(dayTime, OdbcType.DateTime);
            cmdnon.Parameters.Add(hsmt, OdbcType.Numeric);
            cmdnon.Parameters.Add(boft, OdbcType.Numeric);
            cmdnon.Parameters.Add(eaft, OdbcType.Numeric);
            cmdnon.Parameters.Add(j9st, OdbcType.Numeric);
            cmdnon.Parameters.Add(lmbt, OdbcType.Numeric);
            cmdnon.Parameters.Add(fbst, OdbcType.Numeric);
            cmdnon.Parameters.Add(fcbt, OdbcType.Numeric);
            cmdnon.Parameters.Add(fdwpt, OdbcType.Numeric);

            cmdnon.Parameters.Add(fdept, OdbcType.Numeric);
            cmdnon.Parameters.Add(fdbt, OdbcType.Numeric);
            cmdnon.Parameters.Add(ffat, OdbcType.Numeric);
            cmdnon.Parameters.Add(ffpt, OdbcType.Numeric);
            cmdnon.Parameters.Add(fdnpt, OdbcType.Numeric);
            cmdnon.Parameters.Add(ftdt, OdbcType.Numeric);
            cmdnon.Parameters.Add(fppt, OdbcType.Numeric);
            cmdnon.Parameters.Add(fgpt, OdbcType.Numeric);

            cmdnon.Parameters.Add(hsmr, OdbcType.Numeric);
            cmdnon.Parameters.Add(bofr, OdbcType.Numeric);
            cmdnon.Parameters.Add(eafr, OdbcType.Numeric);
            cmdnon.Parameters.Add(j9sr, OdbcType.Numeric);
            cmdnon.Parameters.Add(lmbr, OdbcType.Numeric);
            cmdnon.Parameters.Add(fbsr, OdbcType.Numeric);
            cmdnon.Parameters.Add(fcbr, OdbcType.Numeric);
            cmdnon.Parameters.Add(fdwpr, OdbcType.Numeric);

            cmdnon.Parameters.Add(fdepr, OdbcType.Numeric);
            cmdnon.Parameters.Add(fdbr, OdbcType.Numeric);
            cmdnon.Parameters.Add(ffar, OdbcType.Numeric);
            cmdnon.Parameters.Add(ffpr, OdbcType.Numeric);
            cmdnon.Parameters.Add(fdnpr, OdbcType.Numeric);
            cmdnon.Parameters.Add(ftdr, OdbcType.Numeric);
            cmdnon.Parameters.Add(fppr, OdbcType.Numeric);
            cmdnon.Parameters.Add(fgpr, OdbcType.Numeric);


            while (DbReader.Read())
                       {
                            dayTime = DbReader.GetString(0);
                            Console.WriteLine(DbReader.GetString(0));
                            Console.WriteLine(DbReader["Date / Time"].ToString());
                            hsmt = DbReader["Hot Strip Mill Total"].ToString();     
                            boft = DbReader["Basic Oxygen Furnace Total"].ToString();   
                            eaft = DbReader["Electro-Arc Furnace Total"].ToString(); 
                            j9st = DbReader["J-9 Shop Total"].ToString();
                            lmbt = DbReader["Levy Maintence Building Total"].ToString();
                            fbst = DbReader["Ford Body Shop Total"].ToString();    
                            fcbt = DbReader["Ford Chiller Building Total"].ToString(); 
                            fdwpt = DbReader["Ford Dearborn W Plant Total"].ToString();  

                            fdept = DbReader["Ford Dearborn E Plant Total"].ToString();
                            fdbt = DbReader["Ford Dearborn Balcony Total"].ToString();    
                            ffat = DbReader["Ford Final Assembly Total"].ToString();  
                            ffpt = DbReader["Ford Frame Plant Total"].ToString();  
                            fdnpt = DbReader["Ford Dearborn N Plant Total"].ToString();
                            ftdt = DbReader["Ford Tool and Die Total"].ToString();    
                            fppt = DbReader["Ford Paint Plant Total"].ToString();    
                            fgpt = DbReader["Ford Glass Plant Total"].ToString();  

                            hsmr = DbReader["Hot Strip Mill Rate"].ToString();
                            bofr = DbReader["Basic Oxygen Furnace Rate"].ToString();   
                            eafr = DbReader["Electro-Arc Furnace Rate"].ToString(); 
                            j9sr = DbReader["J-9 Shop Rate"].ToString();          
                            lmbr = DbReader["Levy Maintence Building Rate"].ToString();                                
                            fbsr = DbReader["Ford Body Shop Rate"].ToString();   
                            fcbr = DbReader["Ford Chiller Building Rate"].ToString();
                            fdwpr = DbReader["Ford Dearborn W Plant Rate"].ToString();

                            fdepr = DbReader["Ford Dearborn E Plant Rate"].ToString();
                            fdbr = DbReader["Ford Dearborn Balcony Rate"].ToString();   
                            ffar = DbReader["Ford Final Assembly Rate"].ToString();   
                            ffpr = DbReader["Ford Frame Plant Rate"].ToString();     
                            fdnpr = DbReader["Ford Dearborn N Plant Rate"].ToString(); 
                            ftdr = DbReader["Ford Tool and Die Rate"].ToString();     
                            fppr = DbReader["Ford Paint Plant Rate"].ToString();    
                            fgpr = DbReader["Ford Glass Plant Rate"].ToString();

                            cmdnon.CommandText = "insert into NAT_GAS_READINGS( HSM_TOTAL,BOF_TOTAL,EAF_TOTAL,J9_SHOP_TOTAL,LEVY_TOTAL,BODY_SHOP_TOTAL,CHILLER_BLDG_TOTAL,WPLANT_TOTAL,EPLANT_TOTAL,BALCONY_TOTAL,FINAL_ASSEMBLY_TOTAL,FRAME_PLANT_TOTAL,NPLANT_TOTAL,TOOL_DIE_TOTAL,PAINT_PLANT_TOTAL,GLASS_PLANT_TOTAL,HSM,BOF,EAF,J9_SHOP,LEVY,BODY_SHOP,CHILLER_BLDG,WPLANT,EPLANT,BALCONY,FINAL_ASSEMBLY,FRAME_PLANT,NPLANT,TOOL_DIE,PAINT_PLANT,GLASS_PLANT,DATETIME) values (to_number('" + hsmt + "'), to_number('" + boft + "'), to_number('" + eaft + "'), to_number('" + j9st + "'), to_number('" + lmbt + "'),to_number('" + fbst + "'),to_number('" + fcbt + "'), to_number('" + fdwpt + "'), to_number('" + fdept + "'), to_number('" + fdbt + "'), to_number('" + ffat + "'), to_number('" + ffpt + "'), to_number('" + fdnpt + "'), to_number('" + ftdt + "'), to_number('" + fppt + "'), to_number('" + fgpt + "'), to_number('" + hsmr + "'), to_number('" + bofr + "'), to_number('" + eafr + "'), to_number('" + j9sr + "'), to_number('" + lmbr + "'), to_number('" + fbsr + "'), to_number('" + fcbr + "'), to_number('" + fdwpr + "'), to_number('" + fdepr + "'), to_number('" + fdbr + "'), to_number('" + ffar + "'), to_number('" + ffpr + "'), to_number('" + fdnpr + "'), to_number('" + ftdr + "'), to_number('" + fppr + "'), to_number('" + fgpr + "'), to_date('"+dayTime+"', 'yyyy-mm-dd HH24:MI:SS' ))";
                            int rowsAffected = cmdnon.ExecuteNonQuery();
                            Console.WriteLine(rowsAffected);

                        }


                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.ToString());
                    }
                    finally
                    {
                        conn.Close();                       
                    }
   DbReader.Close();
   DbCommand.Dispose();
   DbConnection.Close();
        }

    }
}

Above is the code that wrote.

My question is does anyone know how I would go about writing a script to automate this code so that it will run every few minutes.
Again, I have no experience writing scripts.

  • 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-23T19:47:08+00:00Added an answer on May 23, 2026 at 7:47 pm

    You can write a batch file that launches your C# exe file.

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

Sidebar

Related Questions

I just finished writing my very first command-line tool in Objective-C, compiled it, and
Writing my first, very simple Rails application, a simple admin app to track work
I am writing a very specialized app in C# that floats as a mostly
I'm writing a very simple text editor and have run into a somewhat minor
I've been writing PHP web applications for some time, and have come across very
I have a very simple TCP server written in C. It runs indefinitely, waiting
I'm writing a script to generate a CSR in Python. The script is very
I'm writing a very simple Android application that showing various shapes on the main
I am writing a very small app that just opens the camera app ready
For the first time, I am writing a web service that will call upon

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.