Hello I am attempting to create a com object that will allow me to connect to an excel spread sheet and then send me back the results. I am new to com objects and got a couple of real simple ones working but this one is making me struggle.<BR><BR>Here is the working page with out no com objects etc.<BR><BR><%@ Page Language="VB" %><BR><%@ Import Namespace="System.Data" %><BR><%@ Import Namespace="System.Data.Oledb" %><BR><BR><script language="VB" runat="server"><BR>Sub Page_Load(sender As Object, e As EventArgs)<BR>Dim myDataset As New DataSet()<BR><BR>''You can also use the Excel ODBC driver I believe - didn''t try though<BR>Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _<BR>"Data Source=C:exceltest.xls;" & _<BR>"Extended Properties=""Excel 8.0;"""<BR><BR>''You must use the $ after the object you reference in the spreadsheet<BR>Dim myData As New OledbDataAdapter("SELECT * FROM [Sheet1$]", strConn)<BR>myData.TableMappings.Add("Table", "ExcelTest")<BR>myData.Fill(myDataset)<BR><BR>DataGrid1.DataSource = myDataset.Tables(0).DefaultView<BR>DataGrid1.DataBind()<BR>End Sub<BR></script><BR><BR><html><BR><head></head><BR><body><BR><p><asp:Label id=Label1 runat="server">SpreadSheet Contents:</asp:Label></p><BR><asp
ataGrid id=DataGrid1 runat="server"/><BR></body><BR></html><BR><BR>================================================== ===============<BR>This is what I tryed to convert to a com object howver I get errors when trying to comile it<BR><BR>Import System<BR>Import System.Data<BR>Import System.Data.Oledb<BR><BR>Namespace myExcelComp<BR><BR>Public Class ExcelAdo<BR> Dim myDataset As New DataSet()<BR> <BR> Public Function GetExcel() As DataGrid<BR> <BR> Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _<BR> "Data Source=test.xls;" & _<BR> "Extended Properties=""Excel 8.0;"""<BR><BR> Dim myData As New OledbDataAdapter("SELECT * FROM [Sheet1$]", strConn)<BR> myData.TableMappings.Add("Table", "ExcelTest")<BR> myData.Fill(myDataset)<BR> <BR> DataGrid1.DataSource = myDataset.Tables(0).DefaultView<BR> DataGrid1.DataBind()<BR> <BR> End Function<BR>End Class<BR>End Namespace<BR><BR>================================================== ===============<BR>Please don't ask me, why I want to do it, or tell me not to do it, I know it is not the most effieicnt way of doing things, but I would really like to try and get this working. If you can offer any assistance in getting this to work I would really appreciate it.<BR><BR>Thank You<BR>LOk although I understand they maybe several issues with the logic used in the above file the first concern, is that the compliler is choking on the imports, with the exception of imports system. I took an example right from Microsofts quickstart and it did the same thing. Do you know what could be causing this? I am running the 21 meg framework not the entire server software (that is on the server) and compiling in dos. Like I said as soon as I try and import namespaces other the system it chokes on them. When I try an example with just the system namespave it works fine.<BR><BR>Thanks for the help<BR>it is "imports", not "imports" for VB files
<BR><BR>Imports System<BR>Imports System.Data<BR>Imports System.Data.OleDb<BR><BR>The rest of the code is going to give you problems also. I suggest that you have your function return the dataset and not a datagrid - take out all the datagrid refs from your function.

