GIDForums  

Go Back   GIDForums > Computer Programming Forums > .NET Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 22-Sep-2009, 12:09
krlo krlo is offline
New Member
 
Join Date: Sep 2009
Posts: 1
krlo is on a distinguished road

Excel and C#


I am having problem when retrieving a column, I do not have a problem when retrieving an entire table here is my code:

C-SHARP / C# Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;


namespace DataWarehouse
{
    public partial class mainfrm : Form
    {
        public mainfrm()
        {
            InitializeComponent();
        }

        private void mainfrm_Load(object sender, EventArgs e)
        {

        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            try
            {
                /*My Select String I am not having problem with 
                 retrieving the entire sheet but when I try to retreive 
                 a column there comes my problem*/
                string select = "SELECT * FROM [Sheet1$]";

                OleDbConnection Conn = new OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;"+
                    "data source=C:\\Book1.xls;"+
                    "Extended Properties=\"Excel 8.0;HDR=NO;IMEX=1;\"");

                Conn.Open();

                OleDbCommand cmd = new OleDbCommand(select, Conn);
                OleDbDataAdapter da = new OleDbDataAdapter();
                da.SelectCommand = cmd;
                DataTable dt = new DataTable();
                DataSet ds = new DataSet();
                da.Fill(dt); //Line 45

                dataGridView1.DataSource = dt;
                
                Conn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
    }
}

my error is:

Quote:
System.Data.OleDb.OleDbException: No Value Given for one or more required parameters
.......
refer to line 45
Last edited by LuciWiz : 22-Sep-2009 at 14:05. Reason: Please insert your C# code between [c#] & [/c#] tags
 
 

Recent GIDBlogToyota - 2009 May Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
MIME download of excel file will not always save to Desktop nawillis .NET Forum 1 21-Jul-2009 15:12
MS Excel 2003 Detect and Repair reversal Metaxa07 Computer Software Forum - Windows 0 04-Sep-2008 15:45
need help for a excel to excel program alyjohn C++ Forum 2 05-Aug-2006 16:08
Copy/Paste from Excel into an FL_Input field UNIX app doesn't work ? jl_nicoue FLTK Forum 1 26-Jul-2006 14:15

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 09:11.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.