Showing posts with label size. Show all posts
Showing posts with label size. Show all posts

Monday, March 26, 2012

Text file size limitation?

I have a program that writes records to a .TXT file.

The code seems to fail when the file reaches the 5mb mark.

Is this a limitation in ASP, or is it related to how much memory I have in the machine?

Thank you.how are you writing to the file?
if you are appending, it should not be a problem.
Well, here's a snippet...


fp = File.CreateText("c:\AccountFinal.txt")

...gather data from 50,000 accounts & other sources, etc here...

fp.WriteLine(BranchNo & AcctType & AcctNo & AcctTitle & totAddr & Phone & SSN & OwnType & SPACE(21) & ActTotals2 & SPACE(41))

fp.Close()

Is there an easier way to do this?

Thanks.
Does it throw an error? If so, what's the error.

Maybe your script times out because it takes to long?
No errors.

Just stops.

It goes through the first 12,000 records (~5mb), then stops.

I change the code to go through the next roughly 12,000 records (~5mb), and it stops again.

... and so on, until I get to the last record.

If I only go through any ~10,000 records, the program finishes normally. (has totals at the end)
Just a wild guess, but could this be related to the database access instead of the writing to file?

I remember from VB6 (a long time ago) that records got read into in blocks, and that you had to do .MoveLast .MoveFirst to get the total amount of records. Maybe there's still something like that, and that it goes wrong when it wants to read the next 'block'

Instead of writing to a file, try incrementing a variable once. If it goes above 12000 the problem is in the file writing, if it stops at 12000 I'm guessing database issue
You might be on to something there. (database issue)

I first changed the code to Append the records to the text file like this...

'Get Records from DBs, and do stuff to them...

fp = File.AppendText(FILENAME)
fp.WriteLine(BranchNo & AcctType & AcctNo & AcctTitle & totAddr & Phone & SSN & OwnType & SPACE(21) & ActTotals2 & SPACE(41))
fp.Close()

It still bombed out, around the same time the previous code did.

I tried your suggestion, and got the same results.

Any thoughts on where I should look next?

Thanks.
How are you getting your results? What database are you using?

I remember something vaguely from MySQL, there there was an option to determine the max size of the request sent back.

The maximum size of a BLOB or TEXT object is determined by its type, but the largest value you can actually transmit between the client and server is determined by the amount of available memory and the size of the communications buffers. You can change the message buffer size (max_allowed_packet), but you must do so on both the server and client ends. See section 7.5.2 Tuning Server Parameters.

http://www.mysql.com/doc/en/Server_parameters.html
max_allowed_packet current value: 1048576

I think this is the one. Don't know if your database has something similar, set to 5MB.
You will have to change the settings in web.config or machine.config file for the file size limit. 5 mb is the default limit set by web.config

Try adding the following lines in the <system.web
<httpRuntime executionTimeout="500" maxRequestLength="72000" /
72000 here refers to approximately 72 mb. change it to the limit you want to set and see if that works.
Access 2k is where all of the account info resides.

Basically, I open the table with the 50k records in a DS, and do a for...Next through the entire file. Do you think this can be part of the problem?

Here is the main routine... I didn't include all of the functions, they really just chain to other tables & grab phone#'s & such.


<%@. Import Namespace="System.IO" %>
<%@. Import Namespace="System.Data" %>
<%@. Import Namespace="System.Data.OLEDB" %>
<%@. Page Language="VB" Debug="true" %
<script language="VB" Debug="True" runat="server"
Public strConn As String = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & server.mappath("db2.mdb") &";"
Dim totAddr, AddressNumber, strPers, strOrg, lblStatus, fName, ActTotals2 as String
Dim myNewRow, totalCount, CKTot, JODTot, IRATot, INDTot, COATot, CSATot, SAVTot As Single
Dim x, fLen as Integer

Sub Page_Load(Src As Object, E As EventArgs)
Dim strSQL AS String = "Select * From Accounts2 Order BY AcctNbr"
Dim GetAcctsCommand As OleDbCommand = New OleDbCommand
Dim Connect as New OLEDBConnection(strConn)
GetAcctsCommand.Connection = Connect
Dim Adapter As New OleDBDataAdapter(strSQL, Connect)
Dim AccountsDS As DataSet = New DataSet
Dim RcdCount As Integer
Adapter.Fill(AccountsDS,"Accounts2")
RcdCount = AccountsDS.Tables("Accounts2").Rows.Count
Dim fp As StreamWriter
Dim AdrNbr, AcctNo, Phone, SSN, AcctType, BranchNo, OwnType, AcctTotal, AcctTitle, tmpField As String
Dim FILENAME as String = Server.MapPath("AccountFinal.txt")

Try
For x= 0 to RcdCount - 1
myNewRow = CType(AccountsDS.Tables("Accounts2").Rows(X).Item("BALAMT"), Single)
If myNewRow > 0 then
totalCount=totalcount + myNewRow
tmpField = AccountsDS.Tables("Accounts2").Rows(X).Item("BranchOrgNbr")
BranchNo = zFill(tmpField, 3)
tmpField = AccountsDS.Tables("Accounts2").Rows(X).Item("AcctNbr")
AcctNo = zFill(tmpField, 13)
AcctType = AccountsDS.Tables("Accounts2").Rows(X).Item("MJAcctTypCd") & SPACE(3-LEN(AccountsDS.Tables("Accounts2").Rows(X).Item("MJAcctTypCd")))
If AcctType = "CK " Then
AcctType = "40"
CKTot = CKTot + myNewRow
Else
AcctType = "10"
SAVTot = SAVTot + myNewRow
End If
OwnType = AccountsDS.Tables("Accounts2").Rows(X).Item("OwnCd") & SPACE(3-LEN(AccountsDS.Tables("Accounts2").Rows(X).Item("OwnCd")))
Select CASE OwnType
Case "JO ", "JA "
OwnType = "JOD"
JODTot = JODTot + myNewRow
Case "S "
If Left(AccountsDS.Tables("Accounts2").Rows(X).Item("CurrMiAcctTypCD"),1) = "R" Then
OwnType = "IRA"
IRATot = IRATot + myNewRow
Else
OwnType = "IND"
INDTot = INDTot + myNewRow
End If
Case "PUB"
OwnType = "COA"
COATot = COATot + myNewRow
End Select
If InStr(AcctTitle, "(Min") > 0 then
OwnType = "CSA"
CSATot = CSATot + myNewRow
End If

AcctTitle = GetTitle(AccountsDS.Tables("Accounts2").Rows(X).Item("AcctNbr"))
SSN = GetSSN(AccountsDS.Tables("Accounts2").Rows(X).Item("PERS_TAXID"), AccountsDS.Tables("Accounts2").Rows(X).Item("ORG_TAXID"))
Phone = GetPhone(AccountsDS.Tables("Accounts2").Rows(X).Item("TAXRPTFORPERSNBR"), AccountsDS.Tables("Accounts2").Rows(X).Item("TAXRPTFORORGNBR"))
If Phone = "" then Phone = Space(14)
AdrNbr = GetAddrNbr(AccountsDS.Tables("Accounts2").Rows(X).Item("TAXRPTFORPERSNBR"), AccountsDS.Tables("Accounts2").Rows(X).Item("TAXRPTFORORGNBR"))
totAddr = GetAddress(AdrNbr)
ActTotals2 = CType(Format(myNewRow,"0000000000.00"), String)
fp = File.AppendText(FILENAME)
fp.WriteLine(BranchNo & AcctType & AcctNo & AcctTitle & totAddr & Phone & SSN & OwnType & SPACE(21) & ActTotals2 & SPACE(41))
fp.Flush()
fp.Close()
lblStatus = "File Succesfully created!"
End If
Next
Catch err As Exception
lblStatus = "File Creation failed. Reason is as follows " & err.ToString()
Finally
End Try
End Sub


I tried all of the other suggestions, now I get this error:

File Creation failed. Reason is as follows System.IO.IOException: The process cannot access the file "c:\inetpub\wwwroot\AccountFinal.txt" because it is being used by another process. at System.IO.__Error.WinIOError(Int32 errorCode, String str) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize) at System.IO.StreamWriter.CreateFile(String path, Boolean append) at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize) at System.IO.StreamWriter..ctor(String path, Boolean append) at System.IO.File.AppendText(String path) at ASP.Accountlist6_aspx.Page_Load(Object Src, EventArgs E) in c:\inetpub\wwwroot\accountlist6.aspx:line 76 DONE!

going to try this next...

"You will have to change the settings in web.config or machine.config file for the file size limit. 5 mb is the default limit set by web.config

Try adding the following lines in the <system.web
<httpRuntime executionTimeout="500" maxRequestLength="72000" /
72000 here refers to approximately 72 mb. change it to the limit you want to set and see if that works. "

I'll let you know what happens.

Thanks.
BTW, if I make the following change, will I need to re-start the web server?

<httpRuntime executionTimeout="500" maxRequestLength="72000" /
Thanks.
That's just a web.config change. You don't even have to recompile for that to take effect, just save it to the server.
Ok, made the last change, now I get this dreaded message:

The page cannot be displayed...

But it looks like the ASPNET_WS.exe process is still going?

Any thoughts on how to keep the page from timing out?

Thanks.
It has to go in the system.web like so


<configuration>
<appSettings>
<add key="connString" value="sss" />
</appSettings>
<system.web>
<httpRuntime maxRequestLength="100000" />
<compilation defaultLanguage="vb" debug="true"></compilation>

Saturday, March 24, 2012

Text Size

I found an issue while working on my asp.net pages in VB. When you open the browser everything looks fine. If a user clicks view and text size and changes the size to larger all my pages are distorted. The text boxes are merged and you cant read them. Does anyone have a solution for this?How are you creating your web page? The pages should look different, but shoudl still be readable. Can you send a short aspx page that demonstrates the behaviour?

Thanks,

Russell
Sounds like you are using GridLayout as you pageLayout (but I could be wrong). I would suggest putting your information (labels and textboxes) in a table. If this dosen't work let me know and I will take a closer look.

Trey
yes I am using a grid layout
I tried to see if there was a difference with a html label or a web form label but they look the same. It seems when the text size is increased by the user it drops the second word in the textbox on another line. How do you know when to use a html label or a web form label?
here a sample

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>trash</title>
<meta content="Visual Basic 7.0" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<TABLE id="Table1" style="Z-INDEX: 103; LEFT: 200px; WIDTH: 128px; POSITION: absolute; TOP: 32px; HEIGHT: 30px" cellSpacing="1" cellPadding="1" width="128" border="1">
<TR>
<TD><asp:label id="Label1" runat="server" Width="95px" Height="22px">web form label</asp:label></TD>
</TR>
</TABLE>
<DIV style="DISPLAY: inline; Z-INDEX: 102; LEFT: 338px; WIDTH: 69px; POSITION: absolute; TOP: 34px; HEIGHT: 25px" ms_positioning="FlowLayout">html
label</DIV>
</form>
</body>
</HTML>
For you table width i would use percents instead of px. I feel it is the best way if you are worried about font size increases. I would also use flowlayout for what you are trying to do. here is an example:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>trash</title>
<meta content="Visual Basic 7.0" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="50%" align="center" border="1">
<TR>
<TD>
<asp:Label id="Label1" runat="server">Label</asp:Label></TD>
<TD>
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox></TD>
</TR>
</TABLE>
</form>
</body>
</HTML>

if you give me exactly what you are doing i can see if i can get it working for you.
It looks like that will do the trick thanks a lot.

Text size on development system and on client?

Greetings,

How should I adjust my text size on my 21(inch) screen so it looks
nicely fit on client's 17(inch), all are with IE 6? I use 'Larger'
text size but it appears large on client's and affecting the overall
look of the aspx page.

MTIA,
Grawsha

ps We all use the same resolution, but I don't know if this is relevanI think all except graphics programs don't care about the actual size of
screen. They usually find place in the screen through system
coordinates(pixels).

So a windows that will occupy full screen in 17 inches monitor with 800 *
600 resolution will also occupy full screen in 21 inches monitor with the
same resolution.
So you should instead worry about the resolution client will use.

I'm not yet familiar with Objects in ASP.NET so I'll simple recommand you to
use Javascript's Screen Object to save screen size infomation in hidden
controls and read them later in the ASP.NET form.

"al" <grawsha2000@.yahoo.com> ?
news:66edfd3c.0405141935.297fef65@.posting.google.c om ?...
> Greetings,
> How should I adjust my text size on my 21(inch) screen so it looks
> nicely fit on client's 17(inch), all are with IE 6? I use 'Larger'
> text size but it appears large on client's and affecting the overall
> look of the aspx page.
>
> MTIA,
> Grawsha
> ps We all use the same resolution, but I don't know if this is relevan

text size setting in VS.Net

As I design my page, I want to make sure it looks good if the Text Size is
set to largest in the I.E browser. How can I set my design view so object
appear that way as I build my page?
Thanks,
T"Tina" <tinamseaburn@.removespamexcite.com> wrote in
news:uSq2pH0LFHA.3708@.TK2MSFTNGP14.phx.gbl:

> As I design my page, I want to make sure it looks good if the Text
> Size is set to largest in the I.E browser.

You do realize that text size is relative... it's not the same on all
computers.

You can attempt to force a standardized size by using CSS.

--
Lucas Tam (REMOVEnntp@.rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Hi,
this is not a problem specific to VS.NET but a generic design issue with
HTML; there is no "setting" you can switch on to "make my site look 'good'
even if user has selected 32pt font and HotDog Windows color scheme at
640x480 resolution, even on Firefox and Mac IE 5.1".

this site has some suggestions if you need to support gigantic font sizes
(could be very reasonable depending on your audience):
http://www.useit.com/alertbox/20020819.html

i think the #1 piece of advice if you really need to support big fonts and
unknown resolutions: keep your page layout very very simple. Simple is not
a bad thing- see: Google.
Option 2: allow users to select an alternate style sheet for big/simple text
version of your pages. If a user has selected large font size they probably
did it for a reason... you shouldnt override their preference. more work
for you though.
Option 3: at beginning of project, put this in your specification: "this
site will be designed for use at bla bla bla resolutions and standard font
sizes", and make sure the client signs off on that and understands the
tradeoffs.

HTH,
Premier JiangZemin

"Tina" <tinamseaburn@.removespamexcite.com> wrote in message
news:uSq2pH0LFHA.3708@.TK2MSFTNGP14.phx.gbl...
> As I design my page, I want to make sure it looks good if the Text Size is
> set to largest in the I.E browser. How can I set my design view so object
> appear that way as I build my page?
> Thanks,
> T

text size setting in VS.Net

As I design my page, I want to make sure it looks good if the Text Size is
set to largest in the I.E browser. How can I set my design view so object
appear that way as I build my page?
Thanks,
T"Tina" <tinamseaburn@.removespamexcite.com> wrote in
news:uSq2pH0LFHA.3708@.TK2MSFTNGP14.phx.gbl:

> As I design my page, I want to make sure it looks good if the Text
> Size is set to largest in the I.E browser.
You do realize that text size is relative... it's not the same on all
computers.
You can attempt to force a standardized size by using CSS.
Lucas Tam (REMOVEnntp@.rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
[url]http://members.ebay.com/aboutme/spot18/[/url]
Hi,
this is not a problem specific to VS.NET but a generic design issue with
HTML; there is no "setting" you can switch on to "make my site look 'good'
even if user has selected 32pt font and HotDog Windows color scheme at
640x480 resolution, even on Firefox and Mac IE 5.1".
this site has some suggestions if you need to support gigantic font sizes
(could be very reasonable depending on your audience):
http://www.useit.com/alertbox/20020819.html
i think the #1 piece of advice if you really need to support big fonts and
unknown resolutions: keep your page layout very very simple. Simple is not
a bad thing- see: Google.
Option 2: allow users to select an alternate style sheet for big/simple text
version of your pages. If a user has selected large font size they probably
did it for a reason... you shouldnt override their preference. more work
for you though.
Option 3: at beginning of project, put this in your specification: "this
site will be designed for use at bla bla bla resolutions and standard font
sizes", and make sure the client signs off on that and understands the
tradeoffs.
HTH,
Premier JiangZemin
"Tina" <tinamseaburn@.removespamexcite.com> wrote in message
news:uSq2pH0LFHA.3708@.TK2MSFTNGP14.phx.gbl...
> As I design my page, I want to make sure it looks good if the Text Size is
> set to largest in the I.E browser. How can I set my design view so object
> appear that way as I build my page?
> Thanks,
> T
>

Text size on development system and on client?

Greetings,
How should I adjust my text size on my 21(inch) screen so it looks
nicely fit on client's 17(inch), all are with IE 6? I use 'Larger'
text size but it appears large on client's and affecting the overall
look of the aspx page.
MTIA,
Grawsha
ps We all use the same resolution, but I don't know if this is relevanI think all except graphics programs don't care about the actual size of
screen. They usually find place in the screen through system
coordinates(pixels).
So a windows that will occupy full screen in 17 inches monitor with 800 *
600 resolution will also occupy full screen in 21 inches monitor with the
same resolution.
So you should instead worry about the resolution client will use.
I'm not yet familiar with Objects in ASP.NET so I'll simple recommand you to
use Javascript's Screen Object to save screen size infomation in hidden
controls and read them later in the ASP.NET form.
"al" <grawsha2000@.yahoo.com> ?
news:66edfd3c.0405141935.297fef65@.posting.google.com ?...
> Greetings,
> How should I adjust my text size on my 21(inch) screen so it looks
> nicely fit on client's 17(inch), all are with IE 6? I use 'Larger'
> text size but it appears large on client's and affecting the overall
> look of the aspx page.
>
> MTIA,
> Grawsha
> ps We all use the same resolution, but I don't know if this is relevan