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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:37:40+00:00 2026-05-30T07:37:40+00:00

Hello I have the code below that for some reason is not working: I

  • 0

Hello I have the code below that for some reason is not working:

I use oledb to fill a dataset from a pipe delimited file that is uploaded through a fileupload control on an asp.net web application. I then take the data table and then use sql bulk copy to copy the data to a table i have setup in sql.

protected void btnUpload_Click(object sender, EventArgs e)
{
    string filepath = fileUpload1.PostedFile.FileName;
    PerformBulkCopy(GencoUpload(filepath));
}

public static DataTable GencoUpload(string path)
{
    string full = Path.GetFullPath(path);
    string file = Path.GetFileName(full);
    string dir = Path.GetDirectoryName(full);

    string connString = "Provider=Microsoft.Jet.OLEDB.4.0;DataSource=\"" + dir +
    "\\\";" + "Extended Properties=\"text;HDR=Yes;Format=Delimited(|)\";";

    string query = "SELECT * FROM " + file;

    DataTable dt = new DataTable();

    OleDbDataAdapter dAdapter = new OleDbDataAdapter(query, connString);

    try
    {
        dAdapter.Fill(dt);
    }
    catch
    {
        // catch code
    }

    dAdapter.Dispose();
    return dt;
}

private void PerformBulkCopy(DataTable GencoInfo)
{
    string conStr = ConfigurationManager.ConnectionStrings["EDI"].ConnectionString;

    using (SqlBulkCopy bulkcopy = new SqlBulkCopy(conStr))
    {
        bulkcopy.DestinationTableName = "dbo.GencoUploadTempTable";
        bulkcopy.WriteToServer(GencoInfo);
    }
}

Can someone help me with why this isnt loading into my sql database? Thank you.

  • 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-30T07:37:42+00:00Added an answer on May 30, 2026 at 7:37 am

    This should do the work……………

           public static DataTable columnNamessheet1(String excelFile)
        {
            string connString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + excelFile + ";Extended Properties='Excel 12.0;HDR=yes'";
            string connectionstring ="Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=DebitCare;Data Source=SSDEV7-HP\\SQLEXPRESS";
    
            using (OleDbConnection conn = new OleDbConnection(connString))
            {
                SqlConnection SqlConn1 = new SqlConnection(connectionstring);
                SqlConn1.Open();
                OleDbCommand odc = new OleDbCommand(string.Format("Select LoanNumber,CustomerName,DateofBirth,MobileNo,SanctionDate,EmployerName FROM [BAJAJ DUMP$]"), conn);
                conn.Open();
                OleDbDataReader reader = odc.ExecuteReader();               
                DataTable sheetSchema = reader.GetSchemaTable();
                SqlBulkCopy sqlbulk = new SqlBulkCopy(SqlConn1);
                sqlbulk.DestinationTableName = "CUSTOMER_DETAILS";
                sqlbulk.ColumnMappings.Add("LoanNumber", "CUSTOMER_LOAN_NO");
                sqlbulk.ColumnMappings.Add("CustomerName", "CUSTOMER_ NAME");
                sqlbulk.ColumnMappings.Add("DateofBirth", "CUSTOMER_DOB");
                sqlbulk.ColumnMappings.Add("MobileNo", "CUSTOMER_MOBILE NUMBER");
                sqlbulk.ColumnMappings.Add("SanctionDate", "CUSTOMER_SANCTION DATE");
                sqlbulk.ColumnMappings.Add("EmployerName", "CUSTOMER_COMPANY NAME");
                sqlbulk.WriteToServer(reader);
                conn.Close();
                return sheetSchema;            
    
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing some code that traverses a structure that may have cyclic references.
I have some strings in Java (originally from an Excel sheet) that I presume
I have a table that has some content in it. Not all rows has
I have a WCF service that returns a stream object. But for some reason
I have a WCF service that returns a stream object. But for some reason
Hello I have the following code namespace ConsoleApplication2 { class Program { static void
Hello i have this form filling javascript: function onLine(code,nn) { document.writeform.bericht.value+=code; document.writeform.bericht.focus(); document.writeform.nickname.value+=nn; write1();
I have following code snippet: class ABC{ public: int a; void print(){cout<<hello<<endl;} }; int
Problem Hello all! I have this code which takes my jpg image loops through
Suppose I have this code: String encoding = UTF-16; String text = [Hello StackOverflow];

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.