473,811 Members | 3,241 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

weird problem with an excel file, asp.net and IIS

Ben
Hi,

i have a weird problem and i don't know who is responsible for this: IIS,
excel or asp.net.
My problem:

we use an asp.net 2.0 application under IIS 6.0 (server 2003 sp2) which must
write data from a form into a table in excel files (i know excel is not
really recommended for that, but it's excel).There are a lot of excel files,
all in the same directory with the same privileges (Network service has
r/w).

There is only a problem with ONE excel file, where it's not possible to
write data (Operation must use an updateable query) and that file is locked
(can't open it) unless i delete the w3wp.exe process.

Can that excel file be 'corrupt' or something? When i open it, there is
nothing abnormal.
Where have i to seatch?
Thanks for advices
Ben

The whole message i get in the Event log is here:

Application information:
Application domain: /LM/W3SVC/1/Root/enquete-2-128275414437394 676
Trust level: Full
Application Virtual Path: /enquete
Application Path: C:\Inetpub\wwwr oot\enquete\
Machine name: SRV754

Process information:
Process ID: 3716
Process name: w3wp.exe
Account name: NT AUTHORITY\NETWO RK SERVICE

Exception information:
Exception type: OleDbException
Exception message: Operation must use an updateable query.

Request information:
Request URL: http://srv754/enquete/ros2rp0607.aspx
Request path: /enquete/ros2rp0607.aspx
User host address: 10.135.181.130
User: CAMPUS\L0386
Is authenticated: True
Authentication Type: Negotiate
Thread account name: NT AUTHORITY\NETWO RK SERVICE

Thread information:
Thread ID: 1
Thread account name: NT AUTHORITY\NETWO RK SERVICE
Is impersonating: False
Stack trace: at
System.Data.Ole Db.OleDbCommand .ExecuteCommand TextForSingleRe sult(tagDBPARAM S
dbParams, Object& executeResult)
at System.Data.Ole Db.OleDbCommand .ExecuteCommand Text(Object&
executeResult)
at System.Data.Ole Db.OleDbCommand .ExecuteCommand (CommandBehavio r
behavior, Object& executeResult)
at System.Data.Ole Db.OleDbCommand .ExecuteReaderI nternal(Command Behavior
behavior, String method)
at System.Data.Ole Db.OleDbCommand .ExecuteNonQuer y()
at enquete.Page_Lo ad(Object sender, EventArgs e) in
C:\Inetpub\wwwr oot\enquete\enq ueteG2.aspx.vb: line 20
at System.Web.UI.C ontrol.OnLoad(E ventArgs e)
at System.Web.UI.C ontrol.LoadRecu rsive()
at System.Web.UI.P age.ProcessRequ estMain(Boolean
includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint)
Jul 3 '07 #1
10 2934
Hi Ben -

My experience with Excel is limited, but I've had a similar problem
with using Access. The real problem here is that, even after you
dispose of your connection to the file, it remains open in the
background (possibly due to connection pooling?). That means the lock
will remain on the file until garbage collection occurs (I've tried
forcing GC to no avail) or the process/web application itself is
stopped.

The typical response from MS is that Excel is not recommended for
this, which you already knew.

You can try to override or bypass the connection pool, but this is
trickier than it sounds; I've heard of some people having success with
that, but I am not one of them. Another (horrible) option is to use
ADO, not ADO.NET, which should really close the file when you tell it
to close.

But the best advice I can give you is that it might be better to
rethink your approach; sometimes not taking the client's requirements
so literally leads to a more stable solution.

Is there any way you can instead use a database server for data
storage, and export the excel files as required from the database?

Good Luck,

-Mark

Jul 3 '07 #2
Ben
Hi, thanks for replying ...

Unfortunately, excel is the only option for this application, because
eveybody can type data into it ...

Could you please explain me how to bypass the connection pool?

"Mark S. Milley, MCAD (BinarySwitch)" <ma*********@bi naryswitch.coms chreef
in bericht news:11******** **************@ k29g2000hsd.goo glegroups.com.. .
Hi Ben -

My experience with Excel is limited, but I've had a similar problem
with using Access. The real problem here is that, even after you
dispose of your connection to the file, it remains open in the
background (possibly due to connection pooling?). That means the lock
will remain on the file until garbage collection occurs (I've tried
forcing GC to no avail) or the process/web application itself is
stopped.

The typical response from MS is that Excel is not recommended for
this, which you already knew.

You can try to override or bypass the connection pool, but this is
trickier than it sounds; I've heard of some people having success with
that, but I am not one of them. Another (horrible) option is to use
ADO, not ADO.NET, which should really close the file when you tell it
to close.

But the best advice I can give you is that it might be better to
rethink your approach; sometimes not taking the client's requirements
so literally leads to a more stable solution.

Is there any way you can instead use a database server for data
storage, and export the excel files as required from the database?

Good Luck,

-Mark

Jul 3 '07 #3
"Ben" <b@bnwrote in message news:Od******** ******@TK2MSFTN GP02.phx.gbl...
Unfortunately, excel is the only option for this application, because
eveybody can type data into it ...
Wow! Who on earth designed this system...???
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Jul 3 '07 #4
Ben
You should better to give an answer otherwise keep your comments for
yourself ...
Those newsgroups are not intented for making your own publicity.

"Mark Rae" <ma**@markNOSPA Mrae.netschreef in bericht
news:Ou******** ******@TK2MSFTN GP03.phx.gbl...
"Ben" <b@bnwrote in message
news:Od******** ******@TK2MSFTN GP02.phx.gbl...
>Unfortunatel y, excel is the only option for this application, because
eveybody can type data into it ...

Wow! Who on earth designed this system...???
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jul 3 '07 #5
"Ben" <b@bnwrote in message news:Ot******** ******@TK2MSFTN GP04.phx.gbl...
You should better to give an answer otherwise keep your comments for
yourself ...
Those newsgroups are not intented for making your own publicity.
OK, then - explain to me how Excel is the "only option" for a data entry
system...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jul 3 '07 #6
Or elect themselves forum police.

"Ben" <b@bnwrote in message news:Ot******** ******@TK2MSFTN GP04.phx.gbl...
You should better to give an answer otherwise keep your comments for
yourself ...
Those newsgroups are not intented for making your own publicity.

Jul 3 '07 #7
Hi Ben -

I'd use this with caution; I can't express enough how much of a bad
design this is. This flies in the face of all the progress that has
been made over the last six years.

That said, here's the old school way to access excel data.

(insert flashback noise and wavy lines here)

For this to work, you'll need to add a reference to ADO (Microsoft
ActiveX Data Objects (any ver))

Dim xl As New ADODB.Connectio n()
'Connection string is different for Excel 2007. Check
http://www.connectionstrings.com for details.
xl.Open("Driver ={Microsoft Excel Driver
(*.xls)};Driver Id=790;Dbq=C:\M yExcel.xls;Defa ultDir=c:\mypat h;")
Dim rs As ADODB.Recordset = xl.Execute("Sel ect * from
[Sheet1$]") 'I.e. excel worksheet name followed by a "$" and wrapped
in "[" "]" brackets.
Do While Not rs.EOF
Debug.WriteLine (rs(0)) 'Example. rs() will take columnname
or column number.
rs.MoveNext()
Loop
rs.Close()
rs = Nothing

'Insert Example. Use the Execute() method for Insert,Update,
and Delete as well.
xl.Execute("ins ert into [Sheet1$] values(""test"" )") 'You may
have to experiement with the exact SQL syntax. I'm pretty sure it
mirrors MS Access.
xl.Close() 'This will really close the file.
xl = Nothing
(/flashback)

Okay; that said, again, I must stress that you're probably better off
coming up with a better data storage solution. You realize, that if
someone has the excel file open on the server, and your code tries to
modify it, you will recieve an error, right?

My job is done here... you know enough to be dangerous now.

Good Luck,

-Mark

Jul 5 '07 #8

Did I say 6? 8 years. I haven't used this method since 1999.

Man, I'm getting old.

Jul 5 '07 #9
"Mark S. Milley, MCSD (BinarySwitch)" <ma*********@bi naryswitch.comw rote
in message news:11******** *************@k 79g2000hse.goog legroups.com...
Did I say 6? 8 years. I haven't used this method since 1999.

Wow! That brought back some (very painful!) memories!
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jul 5 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
35569
by: Allison Bailey | last post by:
Hi Folks, I'm a brand new Python programmer, so please point me in the right direction if this is not the best forum for this question.... I would like to open an existing MS Excel spreadsheet and extract information from specific worksheets and cells. I'm not really sure how to get started with this process. I ran the COM Makepy utility from my PythonWin (IDE from ActiveSTate),
9
3701
by: Ksenia Marasanova | last post by:
Hi, I have a little problem with encoding. Was hoping maybe anyone can help me to solve it. There is some amount of data in a database (PG) that must be inserted into Excel sheet and emailed. Nothing special, everything works. Except that non-ascii characters are not displayed properly. The data is stored as XML into a text field. When I use pgsql it's displayed good in the terminal. Now I run my script and print data
3
20292
by: Otie | last post by:
I found the following under the GetObject help notes and in the example for GetObject: "This example uses the GetObject function to get a reference to a specific Microsoft Excel worksheet (MyXL). It uses the worksheet's Application property to make Microsoft Excel visible, to close it, and so on. Using two API calls, the DetectExcel Sub procedure looks for Microsoft Excel, and if it is running, enters it in the Running Object Table. The...
1
4696
by: mail2atulmehta | last post by:
Hi, I do not know if this is right place for this, but i need some help. I have a text file, whose values are seprated by a delimiter. I want to open this file in excel, ( not import it) . I have written the driver prg in c#. The code opens the file, but it is not writting the values from text file into excel file. I can not figure out the problem here. This is my code: StreamReader dataFileReader = null; FileInfo file = null;...
2
1196
by: KR | last post by:
have a dts package that is run by a scheduled job which was running successfully for several months and suddenly stopped working. The dts package does the following: Truncates the table, does a data pump from a specific excel file to a table on sql server, deletes the excel file. The job does the following: Step 1: Look to see if a file exists and if so, run the dts package. On
2
2901
by: sherifffruitfly | last post by:
Hi, I'm using an adaptation of excel-reading code that's all over the internet - I don't much like or understand it, but it has worked for me in the past.... beggars can't be choosers... : Excel.Application excelObj = new Excel.Application(); Excel.Workbook theWorkbook = excelObj.Workbooks.Open(path+filename, 0, true, 5, "", "", true, Excel.XlPlatform.xlWindows, "\t", false,
0
1079
by: probir.chatterjee | last post by:
Hi, Has anyone encountered similar problem before. I have an webpage in a webapplication that usesDataSet .WriteXml method to write a Log file. The page is meant to export out files in excel and allow me to download an optional export log if need be. The first time around, I click on the export log, everything works like it should. The second time i click on the same button, I receive "Access
1
2113
roswara
by: roswara | last post by:
Dear all, Currently, I am working on a project to make a web-based application using ASP 2.0 and C#. This application will ask user to input for an excel file which has graphs in it. Then the application will grab the graph as image file, and this image will be displayed as thumbnail in the page. Is it possible to accomplish this feature? If it is possible, would you please tell me how? And if it is not possible, why?
11
1271
by: BiffMaGriff | last post by:
Hello, .Net 2.0 I am creating a windows forms application for deployment on a client's machine. The program works fine on my local but the output on the client machine is wrong. Since the problem only occurs on the client's machine I cannot debug it. Essentially the program reads in data from an excell sheet, does some processing and then outputs to a text file the results. I convert the strings from the excel file to doubles and ...
0
9604
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10644
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10379
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10394
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10127
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6882
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5690
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3863
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.