|
You need to actually catch the right error, not just a generic.
Example, if using SQL:
catch (SqlException ex)<br />
{<br />
MessageBox.Show("Error " + ex.Number + " has occurred: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);<br />
}
The only way to speed up a Macintosh computer is at 9.8 m/sec/sec.
|
|
|
|
|
This also does not catch anything. It just runs the query and produces 0 rows (rows is still null).
|
|
|
|
|
I am not following you. How can I get a detailed response on something that does not trigger?
Example:
---
try
{
DataRow[] rows = null;
rows = dataSet.Tables["UserInfo"].Select(query);
}
catch (Exception e)
{
Debug.Print(e.Message);
}
---
When I run this, it won't print anything. Then later on if I check if rows is null, it is (but it shouldn't be because the query above should return jim's row).
|
|
|
|
|
What data provider are you using OLEDB, SQL, ect...?
The only way to speed up a Macintosh computer is at 9.8 m/sec/sec.
|
|
|
|
|
I'm not connecting to an actual database.
I'm just loading the contents of an XML file into a dataset. Then when my app shuts down, it dumps the dataset to an XML file.
I decided to use this method because rather than read/write a large file many times, I just add rows to the dataset (when my program is in use) as well as search the rows. Then at the end it writes the file when the user is done, one time.
If I purposely rename AND to AN (to cause an error), it will say the exact error when I use the standard Exception class.
|
|
|
|
|
This is not something I am familiar with, but an observation:
Age >= '23' AND Age <= '27'
Considering the single quotes is age a number or text. I don't remember how the >= <= applies to text values, but if it is being treated as text could this be causing your problem.
topcoderjax - Remember, Google is your friend.
|
|
|
|
|
Bingo. Well done man, I never would have caught that. It is working 100% as intended now.
However there's still a small mystery to be solved if anyone is up to the challenge. If you remove the "Homes" column from the query and just leave "Age" there by itself, it will work totally fine. It only seems to be a problem when you have more than 1 column having a range check being done to it (with the quotes).
|
|
|
|
|
Create a Winforms application and in the application properties change Common Properties / Output Type from windows application to Console application. When you run application your form will open and a console window will also open. In your form if you call Console.WriteLine the text will appear in the console window. I'm sure there are limitations to this approach (if the console gets closed so does your form), but this may meet your needs. You should be able to use api calls to hide/show the console window if you need to. It might be possible to use api calls to move the console window into your MDI, but I expect this would be very difficult.
topcoderjax - Remember, Google is your friend.
|
|
|
|
|
I've got a very large array of picture boxes that I'm trying to shift with out using a loop. I've tried looping through the array from last element to first, setting the prior element to the current element, however this takes too long.
Basically I want to take the properties from elements [0] to [array length - 1] and set them to elements [1] to [array length]. And then take element [0] and update it programically.
I'm trying to use the Array.CopyTo function, where I copy to a temp array but haven't had any success.
Can anyone help!?!?
|
|
|
|
|
I don't see how looping through the array could be taking too long? Do you have several million items in the array, or what?
Besides, whatever method you try to use instead of a loop will still be using a loop in the end. You will only be wasting resources trying to avoid the inevitable.
Could you show some of your code? That might give a clue to what the problem is.
---
single minded; short sighted; long gone;
|
|
|
|
|
Here's the sample code for what I'm trying to do. I actually have a 2D array. It's an array of pictureBox arrays. If you picture it like a grid with rows and columns. I want to foreach row, I want to shift each column back one, and set the first element to a new image. Here's the code (two for loops)
// Shift the lane to the right //
// Loop through each array (row) //
for(int i = 0; i < allLanes.Length; i++)
{
// Loop through each element in the array (column) //
// From back to front //
for(int j = allLanes[i].Length-1; j > 0; j--)
{
// If the previous element's image is the failed image //
if(allLanes[i][j-1].Image == failImg)
{
// Set the previous element to a pass image //
allLanes[i][j-1].Image = passImg;
// Set the current elemtn to a fail image //
allLanes[i][j].Image = failImg; }
else
{
// Set the current element to a pass image //
allLanes[i][j].Image = passImg;
}
// Thread.Sleep(1); //
}
Note the Thread.Sleep(1). If I remove this, the code start to bomb out saying either: System.Drawing element is in use elsewhere or sometimes the display simply doesn't finish updating with only some of the rows showing the shift.
|
|
|
|
|
Hello,
You shouldn't access the Images and Lanes allways over the index ([i] or [i][j-1]).
Do it once and hold the reference as long as you need it.
This can also be a performance improfement.
All the best,
Martin
|
|
|
|
|
Hi Friends,
I Need help to know how to Insert into MS Access database using C#.net
All help Appreciated,
Sunkkd.
Sun_Light
|
|
|
|
|
Create an OleDbCommand object and an OleDbConnection object. The connection will be used to open a connection to the database. Then use the command object to save the data you want into the database. Google for these two objects to see how it works.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
There are many C# articles on CodeProject, an entire section for "Database" in which you should find the information you seek.
led mike
|
|
|
|
|
|
how do you create a pop up message.
tony-yeyo
|
|
|
|
|
Pop up message hmmmmmmmmm..
MessageBox.Show("Pop up text");:~
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Can you be more specific.
|
|
|
|
|
I have a custom button that I have created which inherits from windows.forms.button. I simply override the mouseenter, mouseover, and mousedown events to paint a custom gradient over the button. In doing so, I must redraw the available image and text. I have been able to align the image with the base. However, I am unable to do the same with the text. Specifically, centering. It is close, just not perfect.
SizeF wSize = graphics.MeasureString(this.Text, this.Font);
float wCenterX = (Width - wSize.Width) / 2;
mTextPt.X = wCenterX;//this does not work properly
mTextPt.Y = Height - 19;// this works fine
e.Graphics.DrawString(this.Text, this.Font, new SolidBrush(this.ForeColor), mTextpt);
For most of the buttons, the text shifts slightly to the left when I use any of the custom events.
Any suggestions would be greatly appreciated. Thanks.
PHD
|
|
|
|
|
The only issue I can see with this code is of rounding off of the wCenterX. Even you have calculated it in float while setting it to the "mTextPt.X" the decimal part will be truncated. But this will have only 1 point difference.
Manoj
Never Gives up
|
|
|
|
|
Thanks Manoj. I checked the precision and it seems to be fine. Any other suggestions?
|
|
|
|
|
I would suggest looking into the StringFormat parameter.
Use this overload of Graphics.DrawString instead:
public void DrawString (
string s,
Font font,
Brush brush,
RectangleF layoutRectangle,
StringFormat format
)
layoutRectangle would be the entire client area of the button (0,0,Width,Height)
For the last parameter, create a new StringFormat, and set the horizontal and vertical alignments to center.
Basically, let the framework do the dirty work.
|
|
|
|
|
Thanks for the suggestion Ian. I should have mentioned that I tried using the StringFormat parameter. There doesn't seem to be any way to "pad" the text when using the StringFormat. Therefore, when you place the text at the bottom of the control, it simply places the text about a pixel or so above the bottom. Therefore, it doesn't align with the base text.
Any other suggestions? Thanks.
|
|
|
|
|
Sorry for the delayed response, but in case you haven't found an answer yet...
If you're centering text, it doesn't really make a difference, but if you're aligning to a side, you might want to shrink the bounding box.
Instead of (0,0,Width,Height), use, say, (2,2,Width-4,Height-4). That'll add a 2-pixel margin on all sides. You could try just tweaking this until it matches up.
|
|
|
|