Hi,
I'm tryin to export a dataset to excel but I keep getting:
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred Additional information: Exception from HRESULT: 0x800A03EC.
On the Interet i've read that I should have something to do with my "culture info". This is my code:
Dim excel As New Excel.Application
excel.Visible = True
excel.UserControl = True
Dim workBook As Object = excel.Workbooks
Dim ds As DataSet
Dim da As OleDbDataAdapter
ds = New DataSet
Dim oConn As OleDbConnection
oConn = New OleDbConnection(mstrConn)
Dim strSQL As String
strSQL = "select * from tblLocation"
da = New OleDbDataAdapter(strSQL, oConn)
da.Fill(ds, "tblLocation")
Dim col As DataColumn
For Each col In ds.Tables("tblLocation").Columns
colIndex += 1
excel.Cells(1, colIndex) = col.ColumnName
Next col
Dim row As DataRow
For Each row In ds.Tables("tblLocation").Rows
rowIndex += 1
colIndex = 0
For Each col In ds.Tables("tblLocation").Columns
colIndex += 1
excel.Cells(rowIndex, colIndex) = row(col.ColumnName).ToString()
Next col
Next row
Anybody who knows how to solve this??
I'm tryin to export a dataset to excel but I keep getting:
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred Additional information: Exception from HRESULT: 0x800A03EC.
On the Interet i've read that I should have something to do with my "culture info". This is my code:
Dim excel As New Excel.Application
excel.Visible = True
excel.UserControl = True
Dim workBook As Object = excel.Workbooks
Dim ds As DataSet
Dim da As OleDbDataAdapter
ds = New DataSet
Dim oConn As OleDbConnection
oConn = New OleDbConnection(mstrConn)
Dim strSQL As String
strSQL = "select * from tblLocation"
da = New OleDbDataAdapter(strSQL, oConn)
da.Fill(ds, "tblLocation")
Dim col As DataColumn
For Each col In ds.Tables("tblLocation").Columns
colIndex += 1
excel.Cells(1, colIndex) = col.ColumnName
Next col
Dim row As DataRow
For Each row In ds.Tables("tblLocation").Rows
rowIndex += 1
colIndex = 0
For Each col In ds.Tables("tblLocation").Columns
colIndex += 1
excel.Cells(rowIndex, colIndex) = row(col.ColumnName).ToString()
Next col
Next row
Anybody who knows how to solve this??