Advertisement

05.21.2008 at 02:14PM PDT, ID: 23422564
[x]
Attachment Details

OLEDB / Excel question

Asked by chlade in Microsoft Visual Basic.Net

Tags: , ,

I am having a problem using OLEDB to read Excel data.  My problem is when there are no records in the Excel file.

To simulate the situation, I opened up a new Excel spreadsheet and saved it without doing anything else.

I then ran the code below.

It gives an error saying "No value given for one or more required parameters."      

What does this mean and more importantly, how can I fix it?

Thanks,
Chris
Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
Imports System.Data.OleDb
 
Public Module Module1
 
    Public Sub Main()
 
        Dim ConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
            "Data Source=C:\_Test\Test Files\Book1.xls;" & _
            "Extended Properties=""Excel 8.0;Hdr=No;ImportMixedTypes=Text;IMEX=1"""
 
        Try
            Using cn As New OleDbConnection(ConnectionString)
                cn.Open()
                Using cmd As New OleDbCommand("SELECT * FROM [Sheet1$] WHERE [F2]='abc'", cn)
                    cmd.ExecuteNonQuery()
                End Using
            End Using
        Catch ex As OleDbException
            MsgBox(ex.Message)
        End Try
 
    End Sub
 
End Module
[+][-]05.21.2008 at 04:06PM PDT, ID: 21619741

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Microsoft Visual Basic.Net
Tags: MS, VB.NET / OLEDB / Excel, 2005
Sign Up Now!
Solution Provided By: Sancler
Participating Experts: 1
Solution Grade: A
 
 
[+][-]05.21.2008 at 04:21PM PDT, ID: 21619810

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.22.2008 at 11:09AM PDT, ID: 21626166

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628