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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:03:26+00:00 2026-05-26T13:03:26+00:00

using (DbCommand command = oconn.CreateCommand()) { command.CommandText = CREATE TABLE [Sheet2$] (F1 number, F2

  • 0
   using (DbCommand command = oconn.CreateCommand())
                {
                    command.CommandText = "CREATE TABLE [Sheet2$] (F1 number, F2 char(255), F3 char(128))";
                    command.ExecuteNonQuery();
                    for (int i = 1; i <= 20; i++)
                    {
                        //now we insert the values into the existing sheet...no new sheet is added.
                        command.CommandText = "INSERT INTO [Sheet2$] (F1, F2, F3) VALUES(1,\"Fake Record\",\"Fake Record\")";
                        command.ExecuteNonQuery();
                    }
                }

I am using this code to insert some records in excel file sheet . What i want to do is to see if for example Sheet1 is there then create sheet 2 and insert these records there . and if it only finds sheet 3 then i want to create another sheet4 and insert the records there and so on. how can i do this?

  • 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-26T13:03:26+00:00Added an answer on May 26, 2026 at 1:03 pm

    Try to check the tables of the data schema:

    DataTable dtSchema = oconn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
    
    DataRow[] dr = dtSchema.Select("TABLE_NAME = 'Sheet1$'");
    
    bool exist = dr == null || dr.Length == 0;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

DbCommand command = new OracleCommand( insert into hardware (HardwareID) VALUES (6);, myConnection); command.ExecuteNonQuery(); Hardware
I'm using a method in the EnterpriseLibrary.Data.Database namespace called public virtual object ExecuteScalar(DbCommand command)
I'm running a number of SQL command using the dot net provider for Firebird
Traditionally when using a DbCommand when retrieving data from a sproc, something like the
I am using EntLib 4.1. _db = DatabaseFactory.CreateDatabase(DbName); DbCommand dbCommand = _db.GetStoredProcCommand(someProcedure); _db.AddInParameter(dbCommand, Id,
Is there an way using ADO.NET to determine if a table exists in a
I want to execute stored procedure with one parameter that returns table using EF4
I seemingly have two choices: Make my class implement IDisposable . Create my DbCommand
It seems that when using the OLE DB Command within SSIS problems occur when
I am trying to write a common Save function and I am using Dbcommand

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.