Hi all,
Below is the code I have been using to extract all the data from an Excel Worksheet and put it into a Dataset :-
MyConnection = New System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; " & "data source=" & ImportFilePath & "; " & "Extended Properties=Excel 8.0;")
MyAdapter = New System.Data.OleDb.OleDbDataAdapter("select * from [" & SheetName & "$]", MyConnection)
MyConnection.Open()
MyDataset = New System.Data.DataSet
MyAdapter.Fill(MyDataset)
MyConnection.Close()
I am now trying to extract an specific cells info from Excel and put it into a specified cell on my datasheet. Can someone give me a code example of how I can acheive this.
Many Thanks
MyAdapter = New System.Data.OleDb.OleDbDat
Dim strSQL As String = MyAdapter.ToString
What you want is just
Dim strSQL As String = "select * from [" & SheetName & "$]"
You are using something different from a DataAdapter, not a version of it. A DataAdapter is really no more nor less than a pre-coded set of commands. It lets you just say .Fill rather than having to code specific commands to get the table structure from the database, create the a datatable with the same structure in you application, call a DataReader to fill the datatable row by row. (It also lets you ask it, once it has a Select command, to create the other commands that are needed to update the database and just call .Update.) But in this setting, you just want a single command which you totally code yourself.
Roger