Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > how to write updated list to excel without having to close the browser first?

Reply
Thread Tools

how to write updated list to excel without having to close the browser first?

 
 
Phil
Guest
Posts: n/a
 
      01-04-2010
Hi,

this code writes a single line to an excel sheet followed by a list of names
coming from a table in the database. The table is chosen from a
dropdownlist.
This works properly.
My problem is: suppose i wrote all the names of a table to excel. Then i
return to the main menu of the application without closing the browser.
Suppose now that the same table with the names is updated (e.g. by another
user who adds some new names). If i start this code below again and then
opening the new excel sheet (or first saving on my desktop), i see exactly
the same names as the previous time, with other words, the new names are not
sent to excel.
In order to see the new names in excel, i have to close the browser and then
restarting it. Even a refresh of the page doesn't help.

Is there no way to get the updated list without having to close the browser
first?
Thanks for help.
Phil

Here the code (vb.net)

Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles
DropDownList1.SelectedIndexChanged
Dim selectedval As String
Dim strLine, filename As String
Dim connection As SqlConnection
Dim dr As SqlDataReader

Dim objFileStream As FileStream
Dim objStreamWriter As StreamWriter

selectedval = DropDownList1.SelectedValue

fileName = "test.xls"
If File.Exists(fileName) Then File.Delete(fileName)

objFileStream = New FileStream(fileName, FileMode.OpenOrCreate,
FileAccess.Write)
objStreamWriter = New StreamWriter(objFileStream)
objStreamWriter.WriteLine("This is sent to an excel sheet")

connection.Open()
Dim sql As String = "SELECT name FROM " & selectedvalue
Dim cmd As SqlCommand = New SqlCommand(sql, connection)
dr = cmd.ExecuteReader()

While dr.Read()
strLine = strLine & dr.GetString(0) & Chr(9)
objStreamWriter.WriteLine(strLine)
strLine = ""
End While

dr.Close()
connection.Close()
objStreamWriter.Close()
objFileStream.Close()
End Sub


 
Reply With Quote
 
 
 
 
Gregory A. Beamer
Guest
Posts: n/a
 
      01-04-2010
"Phil" <(E-Mail Removed)> wrote in
news:#Zpu$(E-Mail Removed):

> Is there no way to get the updated list without having to close the
> browser first?


You have to determine if this is a serious problem or not. How likely is
it going to be that someone adds a new item to the dropdown and someone
already in session is going to have to use it? If "never" then this is
not an issue to spend much time on. Same with "not very often".

Many times we see development problems as production problems, so think
how important it is to "solve" this issue before burning a lot of
cycles.

Having said that, there is little you can do to control a user's browser
cache, unless they are part of a business and you can dictate browser
policy. You can expire the page sooner, which will force it to either
bomb or get the newer bits, but that is about all you can do if the
browser is set with default caching policies.

Personally, I would not use Excel as a data store, as I don't think it
is the proper direction to head, but that is another issue.

Peace and Grace,

--
Gregory A. Beamer (MVP)

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 
Reply With Quote
 
 
 
 
Phil
Guest
Posts: n/a
 
      01-04-2010
ok, thanks
"Gregory A. Beamer" <(E-Mail Removed)> schreef in bericht
news:Xns9CF68327CE269gbworld@207.46.248.16...
> "Phil" <(E-Mail Removed)> wrote in
> news:#Zpu$(E-Mail Removed):
>
>> Is there no way to get the updated list without having to close the
>> browser first?

>
> You have to determine if this is a serious problem or not. How likely is
> it going to be that someone adds a new item to the dropdown and someone
> already in session is going to have to use it? If "never" then this is
> not an issue to spend much time on. Same with "not very often".
>
> Many times we see development problems as production problems, so think
> how important it is to "solve" this issue before burning a lot of
> cycles.
>
> Having said that, there is little you can do to control a user's browser
> cache, unless they are part of a business and you can dictate browser
> policy. You can expire the page sooner, which will force it to either
> bomb or get the newer bits, but that is about all you can do if the
> browser is set with default caching policies.
>
> Personally, I would not use Excel as a data store, as I don't think it
> is the proper direction to head, but that is another issue.
>
> Peace and Grace,
>
> --
> Gregory A. Beamer (MVP)
>
> Twitter: @gbworld
> Blog: http://gregorybeamer.spaces.live.com
>
> *******************************************
> | Think outside the box! |
> *******************************************



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
How to close a TCP socket? (TCPSocket#close doesn't close it) IƱaki Baz Castillo Ruby 7 01-12-2010 01:32 PM
From an ASP page, is there a way write to an EXCEL file without having EXCEL installed on the IIS machine ? fniles ASP General 6 04-27-2009 10:33 PM
Browser close event (MSIE and FF): how to detect browser close ? pamelafluente@libero.it Javascript 0 01-23-2007 12:44 AM
is better to open, write, close file than open, write, append, close? Iulian Ilea Javascript 1 12-21-2006 04:32 PM



Advertisments