|
sir,
Thanks for your suggestions, but what is wrong the for each loop , iam not getting as it will For each Character in this charset, as iam getting all the values in the charaset, iam able to initalize the characters in charset, but during looping only iam getting error
Am i using wrong method of looping foe each values or it is wrong way of using loop,please tell me the
alternate to acheive this
with regards
Radhika
|
|
|
|
|
I never use goto to exit a loop ....
|
|
|
|
|
Ok sir then wat else u use to exit the loop , my problem is that it gives me error only in the
For each loop syntax for this.charset statement, so i will try to resolve it but also suggest ur view wat should i use to exit the loop
your suggestions are really very helpful thanks alot sir for your kind suggestions
with regards
radhika
|
|
|
|
|
loops are best exited with break . If you need to know if some condition was met inside the loop, create a variable outside the loop and set it's value before calling break. You can then check that variable after the loop has completed or been broken out of.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
To elaborate on what Thomas said: take a look at your code:
Label_0104:
foreach (Character character in this.charSet) {
foreach (CharClass class2 in classArray)
{
if (character.type == class2)
{
num17++;
goto Label_0104;
}
}
}
So, you enter the first loop, enter the second, then when you find a match with class2, you go back to before the first loop and enter again.
How are you ever going to to get out of the loop? No wonder you run out of memory first!
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
There is a commonly accepted statement that "goto is evil".
That my be a little extreme, but if it is to be used, it should be done with GREAT caution.
There are very few cases where goto is the best way to control program flow in modern day languages. Rewrite the code without using any goto(s) (and preferably with more descriptive variable naming) and it will be much easier to follow - and will most likely work!
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Label_0104:
foreach (Character character in this.charSet)
{
foreach (CharClass class2 in classArray)
{
if (character.type == class2)
{
num17++;
goto Label_0104;
}
}
}
Stack overflows are often caused by an infinite loop in the code and that's what you have here.
When the condition character.type == class2 is true the outer loop restarts and then when the same condition is encountered for a second time, the loop restarts, and so on. I haven't read your code fully but I suspect that you meant to jump to a point after the end of the outer loop, not just before it's start.
Alan.
|
|
|
|
|
radhikasharma wrote: Label_0104:
foreach (Character character in this.charSet)///Error of stack overflow execption in Charset//
{
foreach (CharClass class2 in classArray)
{
if (character.type == class2)
{
num17++;
goto Label_0104;
}
}
}
What's that dude ????? Are you trying to live in danger ????? If I close my eyes to the ultimate sin (aka goto) the whole situation smells like an eternal loop.
|
|
|
|
|
Thanks for your response sir , please tell me the solution and wat iam doing wrong in the for each loop
please suggest me the right code so that i will not get any stack overflow exception error
also suggest any solution for the above error
with regards
radhika
|
|
|
|
|
Get rid of these goto statements. They produce the stack overflow. Goto is a relic in modern languages . Use a break statement as mentioned by many other people to exit the loop. Avoid by any means to use goto statements.
|
|
|
|
|
How do you keep a Aggie busy?
Write 'Please turn over' on both sides of a piece of paper.
|
|
|
|
|
Thanks alot sir ,my problem is solved
iam very much greatful to you
with regards
radhika
|
|
|
|
|
Where are the num12 , num14 , num20 , num22 and num24 variables?
Greetings - Jacek Gajek
|
|
|
|
|
My guess is someone elses DLL was disassembled.
|
|
|
|
|
It does look like the output from Reflector when used on a .net assembly, that was built in release mode, with the "Optimize code" box checked.
Maybe he should contact the person that wrote the original code to start with, and get the real, (hopefully commented) source. And hope that source isn't copyrighted....
|
|
|
|
|
Hi radhika!
Sorry it's a little late for this reply, but when I looked at your code I nearly cried.
I think your problem is solved, so some other suggestions:
* Invest some time in learning the basics of the environment and language you are using.
(I think you are new to programming) So you learn what type of errors can cause something
like StackOverflowException.
* Thinking about good variable names is never wasted time.
* Posts on any programming forum should never be in the style "I don't understand what you
are talking about - just give me the solution"
* If something compiles it doesn't mean that it is free of errors - NEVER! It just means
it's free of syntax-errors.
* If you have written such a long method - think about how to optimize: code length (maybe
split into several methods), readability (naming, comments, whitespace), functionality...
* Next time you want to use goto: leave it!
Another thing: Maybe you had some reason for all your Add(...Character(...)) lines but to me it looks very strange:
what about:
for(char ch = (char) 0; ch < 128; ch++)
{
}
|
|
|
|
|
Hello.. Sir
i am using a combobox and i am updating it from the database and also inserting value that is in the text of the combobox.its not working fine..
gives an error.........
Item collection cannot be modified when datasource property is set...
Thanks
|
|
|
|
|
when it is giving error? At the time of binding or at cother point.
post code where it gives the error
himanshu
|
|
|
|
|
|
i sent full article of this code to CODEPROJECT .
after that my article being accepted, you can use of them.
but code is like this:
you must use of NORTHWINFD Database
private void button1_Click(object sender, EventArgs e)
{
SqlConnection co = new SqlConnection();
co.ConnectionString = @"Server=.\SQLEXPRESS;initial catalog='NORTHWND.MDF';Trusted_Connection=Yes";
SqlCommand cmdSelect = new SqlCommand();
cmdSelect.Connection = co;
cmdSelect.CommandText = "SELECT (FirstName+' '+LastName) AS Fullname FROM Employees";
SqlDataAdapter da = new SqlDataAdapter(cmdSelect);
DataTable dt = new DataTable();
co.Open();
da.Fill(dt);
comboBox1.DataSource = null;
comboBox1.DataSource = dt;
comboBox1.ValueMember = "Fullname";
co.Close();
}
private void button2_Click(object sender, EventArgs e)
{
DataTable dt = (DataTable)comboBox1.DataSource;
DataRow dr = dt.NewRow();
dr[0] = "< select item >";
dt.Rows.InsertAt(dr, 0);
comboBox1.DataSource = dt;
comboBox1.SelectedIndex = 0;
}
|
|
|
|
|
Hi all
i am doing export to excel operation using below code.
public void ExcelExport(System.Data.DataTable tblExportData, string TempFilePath,string userInfo,bool headerStatus)
{
try
{
Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();
excelApp.Workbooks.Open(TempFilePath, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
//Writing Header in Excel
if (headerStatus == true)
{
for (int i = 0; i < tblExportData.Columns.Count; i++)
{
excelApp.Cells[7, i + 1] = tblExportData.Columns[i].ColumnName;
}
}
//Writing Data in Excel
for (int i = 1; i <= tblExportData.Rows.Count; i++)
{
for (int j = 0; j < tblExportData.Columns.Count; j++)
{
string colName = tblExportData.Columns[j].ColumnName;
excelApp.Cells[i + 7, j+1] = tblExportData.Rows[i-1][colName];
}
}
//Create a worksheet object
Microsoft.Office.Interop.Excel.Sheets sheets = excelApp.Worksheets;
//from the collection of worksheet select one worksheet
Microsoft.Office.Interop.Excel.Worksheet mySheet = (Microsoft.Office.Interop.Excel.Worksheet)sheets.get_Item(1);
//select the cell in the worksheet
Microsoft.Office.Interop.Excel.Range myCell1 = (Microsoft.Office.Interop.Excel.Range)mySheet.get_Range("A6", "A6");
myCell1.Value2 = userInfo;
myCell1.Font.Color = System.Drawing.Color.Black.ToArgb();
excelApp.Visible = true;
}
catch (Exception ex)
{
}
}
it's working fine in local. but when i deployed this on server(e.g.relience server) then it stops to work. i mean exporting to excel not working. Even it's not generating any error and page is redirecting also. can any one help me please.
thanks to you all in advance.
Binod
|
|
|
|
|
Is excel installed on the server? Also improve your error handling, any errors generated are lost with your code.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
I assume that this is being done in ASP.NET??
There's a few things you need to do to ensure that the application works. Note that the official MS line is that Excel is not a server component so they don't provide any support in that respect.
First things first - you'll need to have Excel installed on the server along with the interop assemblies.
Secondly, you need to ensure that the DCOM settings for Excel allow it to be launched from within IIS. You'll need to know what identity your web application will launch Excel as (it's usually NETWORK SERVICE, ASPNET or IUSR_<machinename> depending on your settings and version of IIS). To do this:
Start menu -> Run -> dcomcnfg.exe
Component Services -> Computers -> My Computer -> DCOM Config
Microsoft Excel Application -> Right Click, Properties -> Security Tab
From this tab you need to change the launch, access and configuration permissions to allow full and remote access to the user account you located above.
Next you'll need to do:
Properties -> Identity
select 'Interactive User'.
Finally you'll need to ensure that the webpage launching excel is correctly configured. The interop component expects to be run in a single thread apartment (STA) but ASP.NET defaults to multiple threads (MTA). You can force the use of an STA by including
AspCompat="true"
in the page directive header.
Finally you'll need to modify your web.config file to include a
identity impersonate="true"
section under system.web.
From the way you've written this code, I think you'll end up running into a problem that the instance of excel remains in memory after each export is performed. I don't have time to go into the detail but the problem is that you're not cleaning up objects once they've been disposed of. Note that when you create the export you're actually creating a number of objects (Application, Workbook, Worksheet, Range - at the very least) and all these need cleaning up.
There's articles out there on the web that will explain how to do this though it might take you a bit of trial and error.
Hope that helps!
It definitely isn't definatley
|
|
|
|
|
When one is writing an email in the "To:" textbox, gmail gives you choices of similar coincidences in a combobox-like way:
http://www.youtube.com/watch?v=bWy9SrhUpOM[^]
With the Combobox' AutoCompleteMode set to Suggest I can change the current text of the combobox, but how can I make it add the selection to the end of the current string?
modified on Wednesday, June 17, 2009 1:25 AM
|
|
|
|
|
Trun Yes on the AutocompleteMode and Autocomplete Source(SuggestAppend) properties
|
|
|
|