ASP.NET Reading problem (reading .xls)

W

Wael Soliman

hi all
when i try to read from .xls file in .NET windows application
it work correctly but when i try to use the same connection string in
the asp.net i fail while the connection is the same
i need the right connection string and the rigth way to read .xls file
from asp.net

using ADO.NET in both

best regards
 
G

Guest

Try this using the OLEDBonnection object

Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=FULLYQUALIFIEDPATHANDFILENAMEHERE;Extended Properties=Excel 8.0;
 
G

Guest

Try this ..

Dim sbConn As StringBuilder = New StringBuilder
sbConn.Append("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
filePath)
sbConn.Append(";Extended Properties=")
sbConn.Append(Convert.ToChar(34))
sbConn.Append("Excel 8.0;HDR=Yes;IMEX=2")
sbConn.Append(Convert.ToChar(34))


Dim cnExcel As OleDbConnection = New
OleDbConnection(sbConn.ToString())
cnExcel.Open()
Dim cmdExcel As OleDbCommand = New OleDbCommand("select * from
[sheet1$]", cnExcel)

Dim drExcel As OleDbDataReader
Try
drExcel =
cmdExcel.ExecuteReader(CommandBehavior.CloseConnection)


cmdExcel.Dispose()
If cnExcel.State = ConnectionState.Open Then
cnExcel.Close()
End If
cnExcel.Dispose()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top