-----Original Message-----
Hi Nitromuse,
There are more errors than one and I do not know if I
get them in once so Ihave simplified your code
a litte bit otherwise we could not see the corrections
no more.(It where not that much errors the most important one
was that you did mixup the command and the dataadapter) Sub test()
Dim datagrid1 As DataGrid
(this datagrid1 you have to add to the form also if you
do it in this way,better is just to drag it to your form first)
dim MyConnection as New
System.Data.OleDb.OleDbConnection( _
"provider=Microsoft.Jet.OLEDB.4.0; " & _
"data source=C:\Documents and
Settings\default\My Documents\Payroll.XLS; " & _
"Extended Properties=Excel 8.0;")
dim MyCommand as New System.Data.OleDbCommand ( _
"select * from [Sheet4$]", MyConnection)
dim myAdapter as new data.oledbadapter(mycommand) DS = New System.Data.DataSet
MyAdapter.Fill(DS)
datagrid1.SetDataBinding(DS, "sheet4$")
MyConnection.Close()
End Sub
I think we have the most now.
It was typed by hand, so if you have typos just change
them and tell me ifyou did succeed will you??
Cor
.
Here's what I ended up with to make debug happy and I
still get what I've always gotten since I started ....
Imports System.Data.OleDb
Private Sub Form1_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
Dim DS As System.Data.DataSet
Dim MyCommand As
System.Data.OleDb.OleDbDataAdapter
Dim MyConnection As New _
System.Data.OleDb.OleDbConnection( _
"provider=Microsoft.Jet.OLEDB.4.0; " & _
"data source=C:\Documents and
Settings\default\My Documents\Payroll.XLS; " & "Extended
Properties=Excel 8.0;")
'MyCommand = New
System.Data.oledb.OleDbDataAdapter
MyCommand = New System.Data.OleDb.OleDbDataAdapter
("select * from [Sheet4$]", MyConnection)
DS = New System.Data.DataSet
MyCommand.Fill(DS)
DataGrid1.SetDataBinding(DS, "sheet4$")
MyConnection.Close()
End Sub
End Class
An unhandled exception of
type 'System.Data.OleDb.OleDbException' occurred in
system.data.dll
Any further thoughts ???