|
Hi,
No matter how many mistakes your code contains, it is unlikely to crash the debugger. You are probably getting a run-time exception, which provides you with all the information about what is going wrong and where. Since you are already in the debugger, try to have a look at the content of "LastLine", so do one of the following:
- output the content of LastLine prior to the offending line (e.g.use Console.WriteLine);
- hover over "LastLine" somewhere in that block of code;
- add "LastLine" to the watch window;
- set a breakpoint.
In short, debug your code.
Hint: sometimes index functions return -1.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
Good answer, best hint. Have a 5, or a cookie. Second thought I'm hungry, cookie for me and 5 for you.
|
|
|
|
|
It seems it is actually crashing vhost.exe and the above dosnt stop it
The problem seems to be that there is no way to know how many constrictors before the start of the string .
for example
1% = -1
10% = -2
100% = -3
is there any way to modify the code to prevent this exception ?
|
|
|
|
|
Hi,
you never can trust your inputs, so your code should be defensive. The percent sign may be absent, the number of digits may vary, there might be spaces, etc.
if what you really want is the number which starts at the start of the string and ends just before the percent sign, just locate the percent sign (check for !=-1) and take the substring to the left of it hence LastLine.Substring(0, percentPosition) which you then can easily pass on to int.TryParse() or something similar.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
|
You could buy a book. If you want me to write the code for you I charge by the hour.
|
|
|
|
|
Hey, welcome to the boards. For work you intend to pay for please try rentacoder[^] or codeproject even has a job[^] board.
You will find not many people here will do work for free for you, but you are welcome to read the tutorials and give it a crack and when you get stuck, try posting in the ASP.Net[^] forum, you will get more results. Again, only post specific problems, not a "please do this for me" post.
|
|
|
|
|
Please refrain from deleting messages, they are important so that others may view them and read both your question and the answers that follow.
|
|
|
|
|
Hello Everybody
I have a problem with retreiving data from Example Northwind.sdf database I need your help please !!!!
I`m very new to C# sharp so please be understanding.
So far I got a connection but cannot manage to get data into the text box(i`m using Microsoft Visual C# 2008 Express Edition) I looked into hundreds of examples and still nothing...
this is my CODE
-----------------
private void getDataButtton_Click(object sender, EventArgs e)<br />
{<br />
string conString = Properties.Settings.Default.NorthwindConnectionString;<br />
using (SqlCeConnection connect = new SqlCeConnection(conString))<br />
{<br />
try<br />
{<br />
connect.Open();<br />
MessageBox.Show("Connection Established");<br />
<br />
.....................<br />
.....................<br />
.....................<br />
<br />
}<br />
catch<br />
{<br />
MessageBox.Show("Connection Error!!!");<br />
}<br />
}<br />
}
Dim
|
|
|
|
|
Once you have connected to the database, use SQLCommand and either SQLDataReader or SQLDataAdapter to get the data. Then set this as the text for the textbox.
There are a plenty of examples available on net for doing this.
|
|
|
|
|
Any chacne that you could post one for my code please??
Seriously I have been trying to find solution for last 5 days !
|
|
|
|
|
There's a tutorial here[^]. You should be able to figure it out based on the example, within a day
dimo1982 wrote: Seriously I have been trying to find solution for last 5 days !
Seriously, you won't find ready-to-go solutions that you can copy&paste. Well, not often at least. In stead of trying to find your next solution, just read the documentation, see how the stuff works and make notes.
I are troll
|
|
|
|
|
Can you post your SQL query? Is the connection successful?
Can you give any other details, maybe you have the right direction but simply get caught on something simple (as is usually the case).
Unfortunately no one will write your code for you, but again post the contents of Properties.Settings.Default.NorthwindConnectionString as well as your sql query, and the status of your connection. Then we can help you further.
|
|
|
|
|
Ok as soon as I get back home I will post my code
|
|
|
|
|
I have a multi line log stored in a string in c# , Is there any way to turn the last line of this string to a new string ?
Thanks
|
|
|
|
|
Something like this;
assume s is your string with multiple lines.
string lastLine is your string to hold the last line of your string s.
lastLine = s.Substring(s.LastIndexOf(Environment.NewLine), s.Length - s.LastIndexOf(Environment.NewLine));
Enjoy.
|
|
|
|
|
Hi,
assuming your string's newline matches your system's newline definition, I would try something along these lines:
string lastLine=s;
int lastNewlinePosition=s.LastIndexOf(Environment.NewLine);
if (lastNewlinePosition>=0) lastLine=s.Substring(lastNewlinePosition+Environment.NewLine.Length);
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
Member 6038196 wrote: I have a multi line log stored in a string
From where does that log gets into the string? If it comes from a file, use ReadAllLines and get the last line from the array.
Otherwise you already have replies.
|
|
|
|
|
I want to know about virtual, override & protected in C#.
Pls, write.
Thanks to all.
S. Mustafa Kamal
|
|
|
|
|
Basic stuff like that is explained everywhere, in books, tutorials, articles, specs, so you must be lazy. Here is a cure[^].
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
|
Hi friends,
Why why why????? What have I done so wrong that you guys cant bear me? Leave me, you people dont even reply to my queries even though they aren't malicious at any point. Yes I agree, that once I really asked terrible questions which were malicious and I accepted my guilt. Then why so negative response even now? Well you see, I think somebody on the forum asked about Logic Bombs... and yes, somebody did help him with a link. But I never asked for those destructive program CODES, I just wanted to have the idea.
Why did I come back here???? Well, I surfed all over the web, but did not find any forum comparable to this one. So, I promise to never ever make any mistake by asking about programs which are detrcutive.
PS: I've realised that making destrcutive programs wont bring me any good whereas the contructive ones, can make my life.
What more can I say to proove my innocence??!!!
I calculate my days on earth..... approximately 55 years remaining for me to expire
|
|
|
|
|
Rajdeep.NET wrote: What more can I say to proove my innocence??!!!
but then you say...
Rajdeep.NET wrote: Yes I agree, that once I really asked terrible questions which were malicious ...[sic]
So you are infact not innocent. Go back to the c++ forum, they make cool uber 1337 shiz there. It's a totally far easier language to grasp and it's concepts are super easy and you don't even need this whole complicated framework bull. I mean, you can do anything you want. Try it, go there. Stay there.
PS to community; my bad, I said his name.
|
|
|
|
|
Rajdeep.NET wrote: Hi friends
Doubtful.
Rajdeep.NET wrote: I surfed all over the web
Doubtful, it would take you years. (And you may be locked up for looking at all that kiddy pr0n)
This[^] is something you might find useful.
Seriously, no-one here condones malicious code, which you lied about.
Rajdeep.NET wrote: What more can I say to proove my innocence?
That doesn't make any sense; seeing that you have already said you are guilty.
ps. This is not appropriate for this forum, please feel free to post in here[^]; to keep the trolls happy.
My failometer has shot off the end of the scale!
I seem to have misplaced my ban button.. no wait... found it!
|
|
|
|
|
Rajdeep.NET wrote: Hi friends
No. I am quite picky about who I refer to as "friends". You definitely do not qualify.
Rajdeep.NET wrote: Why why why????? What have I done so wrong that you guys cant bear me?
You need a list? You need a memory?
Rajdeep.NET wrote: Yes I agree, that once I really asked terrible questions which were malicious and I accepted my guilt.
and
Rajdeep.NET wrote: What more can I say to proove my innocence??!!!
are mutually exclusive. You cannot be innocent and guilty (even in Britain, yet)
Three exclamation marks are "the sign of a diseased mind".
Rajdeep.NET wrote: Then why so negative response even now? Well you see, I think somebody on the forum asked about Logic Bombs... and yes, somebody did help him
When it was clear that he had used the wrong term, and malicious intent was not involved.
Rajdeep.NET wrote: I calculate my days on earth..... approximately 55 years remaining for me to expire grow up
FTFY
If you are going to quote people, at least have the grace to get it right. Unlike you, I can use punctuation, have never made assumptions about your sex, and would not use the same word three times in a row, without any proper sentence structure. BTW, "somebody" is a complete word; there is no need to CamelCase it.
OriginalGriff wrote: Please, please, don't mention that name (he might come back)
Now, go away and find somewhere suitable for your undoubted coding talents (the Tufty Club, perhaps, or Here[^])
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
|
|
|
|