Hi rajaloysious -
The build is returnng the error:"Type or namespace 'Server' could not be found (missing a using directive or assembly refernce)"
at:
"Data Source=" + Server.MapPath("../ExcelDa
I tried replacing this with the datasource hard coded:
"Data Source=T:\DB_DEVELOPMENT\c
this returns the error: "Unrecongnized escape sequence"
help :-)
Main Topics
Browse All Topics





by: rajaloysiousPosted on 2005-08-24 at 02:06:30ID: 14740724
should be quite simple - ) om/default .aspx?scid =kb%3Ben- u s%3B306572
EDB.4.0;" + ta.xls") + ";" +
nString);
t1, "XLData");
ultView;
see here for more info -- http://support.microsoft.c
below is the code you need...
cheers
using System.Data.OleDb;
using System.Data;
// parameter as appropriate for your environment.
String sConnectionString = "Provider=Microsoft.Jet.OL
"Data Source=" + Server.MapPath("../ExcelDa
"Extended Properties=Excel 8.0;";
// Create connection object by using the preceding connection string.
OleDbConnection objConn = new OleDbConnection(sConnectio
// Open connection with the database.
objConn.Open();
// The code to follow uses a SQL SELECT command to display the data from the worksheet.
// Create new OleDbCommand to return data from worksheet.
OleDbCommand objCmdSelect =new OleDbCommand("SELECT * FROM myRange1", objConn);
// Create new OleDbDataAdapter that is used to build a DataSet
// based on the preceding SQL SELECT statement.
OleDbDataAdapter objAdapter1 = new OleDbDataAdapter();
// Pass the Select command to the adapter.
objAdapter1.SelectCommand = objCmdSelect;
// Create new DataSet to hold information from the worksheet.
DataSet objDataset1 = new DataSet();
// Fill the DataSet with the information from the worksheet.
objAdapter1.Fill(objDatase
// Bind data to DataGrid control.
DataGrid1.DataSource = objDataset1.Tables[0].Defa
DataGrid1.DataBind();
// Clean up objects.
objConn.Close();