|
Have a look at Exception.TargetSite then.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
u can get the current class and method name like this.
Below as a class variable.
private static readonly string _className =
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString();
Put below code inside each function that u want to log.
string thisMethod = _className + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()";
then whenever u want to log the info, u can just simply use
logger.info("Error Occurred + thisMethod);
|
|
|
|
|
jojoba2010 wrote: 2) Where I save this log info.
I mean shall i save them in XML or word File ?
you can save the data anyways you want it. xml is structured and easier to browse through. text is easy to implement.
jojoba2010 wrote: 1) How can I have Log for error in try catch with this informations
1.Error Name :
2.Form Name:
3.Function Name that error occurred :
4.Date_Time when error occurred :
void AddLogEntry(String errorName, String formName, String functionName)
{
DateTime entryTime = DateTime.Now;
}
or, you can do this:
void AddLogEntry(Exception ex)
{
String errorName = ex.message;
String trace = ex.StackTrace;
DateTime entryTime = DateTime.Now;
}
hope this helps and good luck ![Smile | :)](https://www.codeproject.com/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
Hi All,
i am using DataGridView which contains 4 Columns in my c# 2005 application .
When the user types some data in Column 1 and press enter the focus should go to Column 3 (or some other column) of the same row. in short how can i do programmatically set focus to specific cell(column) in a DataGridView.
how can i achive this i serached info but not able to find any relavent data .
|
|
|
|
|
Vijjuuuuuuuuu........... wrote: in short how can i do programmatically set focus to specific cell(column) in a DataGridView
By setting the CurrentCell[^] property
I are Troll
|
|
|
|
|
Hi Eddy,
Thanks for you reply .
sorry to ask you again not clear with the example given ,
my requirment is ,focus should move to paticular cell (i will specify the row and column number) when the user is inputing the data .
|
|
|
|
|
Vijjuuuuuuuuu........... wrote: my requirment is ,focus should move to paticular cell (i will specify the row and column number) when the user is inputing the data .
You can set the input-focus using the property "CurrentCell", like this;
dataGridView1.CurrentCell = dataGridView1[3, 4];
There's a "howto" article on this subject on MSDN[^]
I are Troll
|
|
|
|
|
Thank you very much for your prompt reply .
Now i am facing new problem, celling focusing is not correct.
its is focusing one row next to mentioned index .
for example i have 4 columns for my grid.
dataGridView1.CurrentCell = dataGridView1[0,2];
for the above code the focus to [1,2]
any idea ? if not pls igorne my quesiton.
|
|
|
|
|
Hi friends,
Can you'll help me to find another way for this..
i have two bitmaps, one is the mask bitmap which is a grey scale image and another is actual image, i am applying this mask on the image, i use getpixel & setpixel to apply the color of mask image as the alpha of the other image.. for small images it is fast but it becomes slow as the image size increases.. Is there any alternate way to do so?
Thanks in advance..
Regards
Samir
|
|
|
|
|
VCsamir wrote: i use getpixel & setpixel
These methods are really VERY slow.
VCsamir wrote: Is there any alternate way to do so?
Yes.
- One of the alternative methods is to lock the bits of your bitmap in memory and perform a direct access to the bitmap bits using unsafe block. There are plenty of examples and here[^] is a very brief one.
- Another option is to hide this pointer arithmetic in a class and provide some fast GetPixel and SetPixel implementations. You can find such a class in this[^] article (it is named UnsafeBitmap ).
- The third option is using ColorMatrix[^]. Here are some examples of its usage: 1[^], 2[^]. You can find more...
I'd also suggest you to have a look at this article and the other parts of the series: Image Processing for Dummies with C# and GDI+ Part 1 - Per Pixel Filters[^]
I hope this helps. ![Smile | :)](https://www.codeproject.com/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
Thanks Sir for kind Help!!
Regards
Samir
|
|
|
|
|
You're welcome! ![Smile | :)](https://www.codeproject.com/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
I have a problem when trying to compare two strings with different fonts.
the following comparison returns me a false result.
Assert.AreEqual("B", SomeFunction());
where
public string SomeFunction()
{
return value of a cell of Excel file using different Font;
}
in my case SomeFunction return a big big B.
Thanks for helping
|
|
|
|
|
|
We're a bit impatient today, aren't we?
It usually takes a day or two to get a reply here, as most of our members have real jobs and can't spend all their time surfing the site for questions to answer. Be more patient, and you will be rewarded.
As a beginner myself, I'm not an authority to depend on, but the first thing I noticed about your post is that your code is using Assert to do a simple comparison. I did a bit of research and found that Assert is a method used in debugging, not application code. And specifically, the .IsEqual method is really thorough, and will fail if there is anything at all different between two arguments, including fonts.
I suspect that you are trying to compare the character values, and so I wonder why you don't first cast the imported value from Excel to a string type, then use a simple if (A == B) comparison. Post a bit more of your code, and maybe you will be rewarded with a better answer.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
Thank you for replying.
In my code, i use Assert.AreEqual(strA,strB) to compare two string (this function is in NUnit Framework -test driven development).
Where strA is "B" and strB = a string value returned from my SomeFunction.
Again Thanks.
|
|
|
|
|
In code a character is a character; it has no font properties. Comparing "B" to "B" will always yield equal regardless of how those characters are displayed on screen or paper.
huonghue wrote: where
public string SomeFunction()
{
return value of a cell of Excel file using different Font;
}
in my case SomeFunction return a big big B.
This is not possible unless your function is returning a bitmap image of a large character.
MVP 2010 - are they mad?
|
|
|
|
|
Thanks for replying to my post.
One thing i didn't tell is that my excel file used Japanese font. When i open excel file i see B character, but for some reason it's not B but big B.
Thanks.
|
|
|
|
|
huonghue wrote: it's not B but big B.
???
MVP 2010 - are they mad?
|
|
|
|
|
I read that if I successfully insert one row of data or delete one row of data, the sql server will return me 1.
But when I try it, it returns me -1 instead of 1 although the row of data is successfully inserted or deleted.
Anyone here could enlighten me if I got something wrong? Thank you very much in advance.
SqlConnection con = new SqlConnection(GUIInitializer.DBconnectionString);
SqlCommand cmd = new SqlCommand(GUIInitializer.stp_GUI_DELETEITEMAIRLINEMAPPING, con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@ITEM_CODE", itemCode);
con.Open();
int rows = cmd.ExecuteNonQuery();
con.Close();
if (rows == -1)
{
DeleteItemData(itemCode);
}
else
MessageBox.Show("Item Code: " + itemCode + " Deletion FAILED!");
|
|
|
|
|
For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command. For all other types of statements, the return value is -1. If a rollback occurs, the return value is also -1.
|
|
|
|
|
Thank you for the reply..
But the above code currently, returns me -1 even though only one row is affected. Is there anything wrong with the code?
Thanks again.. ![Smile | :)](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
I think you should put "SET NOCOUNT ON" in Top of your SP and "SET NOCOUNT OFF" At the end of your SP
THANKS
|
|
|
|
|
Hi, Just tried it out. But still cannot. The insert is still replying me -1 when one row of data is added. But the delete is ok without adding NoCount.
Thank you for your help.
|
|
|
|
|
ok..got it..sorry for the trouble..
I didn't put the ( ) when I declare the variables in STP.
CREATE PROCEDURE [dbo].[stp_GUI_InsertAirlineData] (
@AIRLINE_CODE varchar(3),
@AIRLINE_DESC nvarchar(50) )
|
|
|
|