Advertisement
| 03.04.2008 at 01:17PM PST, ID: 23214096 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: |
'The connection string.
Dim xlCon As String = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & lblImportFile.Text & _
";Extended Properties=""Excel 12.0;HDR=YES"""
Try
'Excel "SELECT" statement
XlsSQL = "Select * from [Sheet1$]
'Declare and instantiate the connection object.
Dim con As New OleDbConnection(xlCon)
'Declare and instantiate the command object.
Dim com As New OleDbCommand()
'Declare and instantiate a DataAdapter which fill the dataset with data.
Dim da As New OleDbDataAdapter
'Add values to the command object's properties.
With com
.Connection = con
.CommandType = CommandType.Text
.CommandText = XlsSQL
End With
With da
.AcceptChangesDuringFill = False
.SelectCommand = com
'Add data to the dataset.
.Fill(dsXLData, "Ratings")
End With
MsgBox(dsXLData.Tables("Ratings").Rows.Count & " Rows")
MsgBox(dsXLData.Tables("Ratings").Columns.Count & " Clmns")
da.Dispose()
con.Dispose()
|