Passing a user Id to oledbdataprovider to access XL spreadsheet.

  • Thread starter Thread starter AlexB
  • Start date Start date
A

AlexB

I had been successfully accessing an XL spreadsheet using
the OleDBDataadapter with the code below, until the
Security department set permissions on the file. Now this
code cannot access it even though the account that the
aSP.NET is running under has permissions to the file.

I tried using "Integrated Security=SSPI" in the
connectionString but it didn't work either.

I think the only problem is that I need to tell the OLEDB
provider to use a certain user id. Anyone have any ideas
how to make this work?


Dim DA As New OleDb.OleDbDataAdapter()
Dim Conn As New OleDb.OleDbConnection()

Conn.ConnectionString
= "provider=Microsoft.Jet.OLEDB.4.0; " & _
"data source=" & psXLFile & ";" & _
"Extended Properties=Excel 8.0;"

' Get source data
DA = New OleDb.OleDbDataAdapter("Select * From
[" & psSheet & "$]", Conn)
DA.Fill(DT)
 
Not sure if this will work, but have you tried using the
uid= and pwd= to pass the user id and password? Note that
using this method the id and password need to be in
cleartext which is obviously a bad thing in a domain.

Jeff Levinson

Author of "Building Client/Server Applications with
VB.NET: An Example Driven Approach"
 
You may need read/write permission to this file's folder and the system
temporarily folder. You may try to se the ASP.NET's account to local
administrators group to see if it will help.



Luke

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Back
Top