.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Unusual problem using a class method

Posted By:      Posted Date: September 28, 2010    Points: 0   Category :ASP.Net

I have a class that runs calculations on numbers and populates the results to my SQL database.  My code behind page instantiates the class object, and in a loop it makes use of the method five times (once per loop).  Essentially, my code behind collects the information from controls and passes the information to the class method for processing.  The method works just fine most of the time.

On one of the iterations I get a error before the code even gets to the class.  The error is, "Arithmetic operation resulted in an overflow."  What strikes me as odd is that while stepping through the code, the loop crashes with that error before getting to the class that runs the calculations.  Additionally, no arethmetic operations are performed on the form's code-behind page (which calls the method).  I even put a break-point on the class constructor but the code crashed before reaching that constructor.

The information being sent is the results of matches from a sporting event.  As a troubleshooting measure I changed the order of the matches by deleting them an re-entering them into the database in a different order.  Again only this one particular match crashed.

Here is the code that crashes:

cRating.SetRating(dMatchDate, iSetID, 8, iHPlayerID, 

View Complete Post

More Related Resource Links

Problem with Finder method with parameters



Could someone explain me how to provide some value to the parameters in a finder method. For exemple I know that the BDC list WP use this method. Is there a way to provide some value for those parameter at runtime? I really don't understand (even after some deep search on the web) where are the values for the parameters from and how we can connect to them. Even with C# code I can't find any information on how it work.

I don't want to define my parameters as filter in the ADF because then I will have this filter section in my BDC list WP (or is there a way to get rid of that?). Actually one of the parameter should be automatically calculated from a value in a SP list, the other parameter should be provided by my own filter web part.

Thank you for your help.

Problem with Scripter class in powershell

tweaked my wits on this one. can't figure it out!i'm trying to follow the steps at the bottom of this page http://www.mssqltips.com/tip.asp?tip=1842  [System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO')| out-null # Create an SMO connection to the instance$s = new-object ('Microsoft.SqlServer.Management.Smo.Server') "LOCALHOST\SQL2005_1" $dbs = $s.Databases$dbs["Northwind"].Script() | Out-File D:\PSScripts\NWind.SQL $scrp = new-object ('Microsoft.SqlServer.Management.Smo.Scripter') ($s) $scrp.Options.AppendToFile = $True$scrp.Options.ClusteredIndexes = $True$scrp.Options.DriAll = $True$scrp.Options.ScriptDrops = $True$scrp.Options.IncludeIfNotExists = $True$scrp.Options.IncludeHeaders = $True$scrp.Options.ToFileOnly = $True$scrp.Options.Indexes = $True$scrp.Options.WithDependencies = $True $scrp.Options.FileName = "D:\PSScripts\NWind.SQL"$scrp.Script($dbs["Northwind"].Tables) I changed the instance, database, and file paths[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO') | out-null $s = new-object ('Microsoft.SqlServer.Management.Smo.Server') "LOCALHOST"  $dbs=$s.Databases #$dbs["AdventureWorks"].Script()  $dbs["AdventureWorks"].Script() | Out-File C:\temp\myscript.SQL   $scrp = new-object ('Microsoft.SqlServer.Manag

Extension Method ForEach for ArrayList class

Hi,I need to create an extension method(ForEach) for arraylist classI have created an extension method for Array class but cannot do that for arraylist.Please help me namespace MyExtension { public static class IEnumerableExtension { public static void ForEach<T>(this IEnumerable<T> list, Action<T> action) { if (action == null) throw new ArgumentNullException("action"); foreach (T item in list) { action(item); } } } } Any Help Shall be appreciatedThanks

Calling a method with a class object as parameter data type.

   [WebMethod]    public string GetInfo(Customer inCust)    {        // Code in here    } I have a web service that resides on a remote server. I want to call a public method of theweb service named  "GetInfo". The method is shown above. The web service method expects a class object oftype "Customer". What I did to create a Customer object was to define in my asp.net project my own class named "Customer" which is exactlythe same as the class that belongs to the web service project on the remote server. I then created an instance of Customerand tried to call the web service passing in an object of type customer : my.Service ws = new my.Service(); // Get web service connectionCustomer aCustomer = new Customer();aCustomer.Initialize();ws.GetInfo(aCustomer) // call web service passing in a Customer object The problem is that the compiler gives me the following error: Value of type '_Default.Customer' cannot be converted to 'ws.Class1'. Here Default is refering to my Default.aspx.cs code. Why is this? Do I need to Cast my "aCustomer" class object to a type ofws.Customer ? How do I do that?

Sending Array of Custom Class over WCF Problem

I have been attempting to convert some service calls that returned a DataSet into something more lightweight. For instance, I am converting: [OperationContract] public DataSet GetCommittees(); into: [OperationContract] public List<VolunteerCommittee> GetCommittees(); where committee is defined as: [DataContract] public class VolunteerCommittee { [DataMember] public int Id { get; set; } [DataMember] public String Name { get; set; } } I copied the structure of the data contract and the operation contract right from an example in a book I bought on WCF. The author mentioned that the List<VolunteerCommittee> would get converted into an array over the wire, so the client's operation contract looks like: [OperationContract] public VolunteerCommittee[] GetCommittees(); My problem: When the service is called, an empty array is returned every time. When I put trace statements in, I see an array of 48 VolunteerCommittees leaving the server. I've done some reading on the problem and tried a number of suggestions, such as using the XmlSerializer attribute, including a certain namespace as a [return:] on the server's contract, changing the type of binding (it's using wsHttpBinding... I tried basicHttpBinding) and turning off MTOM in the behavior, but none of these changed the empty result of the call. At this point, I'm hoping someone can shine some light on

Dithering problem with Bitmap class

I have a scanned document(black and white in color), which is typed through a word processor. So, I each letter is very crisp in the image and is not overlapping with any other character. But once I load that into Bitmap class I see that because of dithering the words get connected by gray color.   How can i make sure, that when we are loading the image in Image or Bitmap class we can avoid dithering at all. It means that if the system can find the exact color then map it otherwise leave the pixel untouched and dont fill any color(let's say leave it as white).  suneeelid2000@gmail.co

[] brackets before a class or method Declaration

Hi Guys,Some times we have [] brackets before a class or method Declaration.  Can anyone guide me please in understanding those squre brackets.  what do we write in those and what they represent. like this [SerializableAttribute][ObsoleteAttribute]class Moon { }Thanks in advance.

Problem with overriding OnPaint method of System.Windows.Forms.Textbox

Hi,   I want to change the border colour of the Textbox. However, when I override the OnPaint method, some strange behaviour occurs.   The new border is drawn, as is the textbox background. However, the text itself appears in bold and only while I actually type something in, afterwards it disappears. I have provided a sample of my code here:         protected override void OnPaint(PaintEventArgs e)         {             base.OnPaint(e);             Rectangle rect = new Rectangle(0, 0, this.Width, this.Height);             ControlPaint.DrawBorder(e.Graphics, rect, _BorderColour, ButtonBorderStyle.Solid);         }   I have also set the style of the control to Userpaint, so that the paint method is actually used. Does anybody know how to solve this issue?

Is it possible to add a class method to CLR base class like Date?

Hi All, I would like to add a class method like ParseYYYYMMDD to the Date base class. So that I can use the following code. Dim result As Date = Date.ParseYYYYMMDD(dateString) Any idea? Is it possible via extension? Thanks! Regards, AlexAlex Lau from HKSAR

how to get a class reference as a reference and not a string to send for a generic method

I got some property that i get using generic method, there for I dont have it's <T>and I want to send it to another generic method but , how the heck do I get it's <T> :P?please look at the code below to understandit gets an entity framework objects, scan all it's properties and if the property is another entity framework object it would send it back to him self , the issue is that i dont know the new object <T> to send it back to him self :(search for the bold part to see what i'm missing//contains objects which we added so there wont be double adding private List<object> _addedObjects; public FakeGenericRepositoryExtension() { _addedObjects = new List<object>(); } public void Create<T>(T entity) where T : class { //add to created objects _addedObjects.Add(entity); //do something with object //... //start recircle process Type entityType = typeof(T); //run thrue each member of Type foreach (var member in typeof(Type).GetProperties()) { //get member value var member_value = member.GetValue(entity, null); //if not null //we must test this otherwise we can't get .BaseType if (member_value != null) { //get current member's base type string memberBaseType = member.GetValue(entity, null).GetType().BaseTyp

Problem using value() method for xml datatypes.

Hi i'm working on an application which stored infopath forms in database as xml datatype. now i want to get query of xml data which returns each node as sql dataType (column). here is my sample form data : <?mso-infoPathSolution solutionVersion="" productVersion="12.0.0" PIVersion="" href="file:///D:\customForm3.xsn" name="urn:schemas-microsoft-com:office:infopath:customForm3:-myXSD-2010-09-11T10-56-47" ?> <?mso-application progid="InfoPath.Document" versionProgid="InfoPath.Document.2"?> <my:myFields xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2010-09-11T10:56:47" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" xml:lang="en-us"> <my:txtFirstName>test1</my:txtFirstName> <my:txtLastName>test2</my:txtLastName> <my:txtFatherName>test3</my:txtFatherName> <my:txtNationalCode>8278273828</my:txtNationalCode> <my:cmbReuqesType>2</my:cmbReuqesType> <my:dtmRequestDate>2010-09-17</my:dtmRequestDate> <my:txtDescription>test4</my:txtDescription> </my:myFields> to get query of this

problem in newform.aspx override class

Hi All Im facing a wierd problem, I have a custom list, im trying to override its newform.aspx page class with custom class. in Page_load event of the class Im checkig for one value in query string, if value exists then I have to select a dropdown field in the list. other wise not to select any value. After that i save the record.  Here only the PROBLEM comes. when I use my code it is NOT inserting new record. When I comment my code it is inserting new record. I do not understand whats the problem in my code. PLEASE help me to overcome this. Here is the code protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { //When ERID is not null, it means request is coming from employee page if (HttpContext.Current.Request.QueryString["ERID"] != null) { FinishMyJob(); } } private void FinishMyJob() { SPSecurity.RunWithElevatedPrivileges(delegate() { string _StaffAppRecId = null; Boolean _IsFound = false; SPWeb _web = SPContext.Current.Web; SPList _list = _web.Lists[SPContext.Current.ListId]; SPList _lstEmp = _web.Lists["Employee"]; SPListItem _EmpLstItem = _lstEmp.GetItemById(Convert.ToInt32(HttpContext.Current.Request.QueryString["ERID"])); string _strEmpName = Convert.ToStri

Problem with HijriCalendar class

The minimum supported date for HijriCalendar class is 1/1/1 which is equivalent to the gregorian date of July 18th, 622. Now when I try to pass that date to HijriCalendar.GetYear with HijriAdjustment set to -1 I get the following exception  [ArgumentOutOfRangeException: Valid values are between 1 and 9666, inclusive. Parameter name: year] System.Globalization.HijriCalendar.GetDaysInYear(Int32 year, Int32 era) +5405139 System.Globalization.HijriCalendar.GetDatePart(Int64 ticks, Int32 part) +199 System.Globalization.HijriCalendar.GetYear(DateTime time) +41 Here is the code to reproduce the problem: private static void TestHijriAdjustment(int adjustment) { HijriCalendar calendar = new HijriCalendar() { HijriAdjustment = adjustment }; try { Console.WriteLine("HijriAdjutment = {0}, Year = {1}", adjustment, calendar.GetYear(calendar.MinSupportedDateTime)); } catch(ArgumentOutOfRangeException ex) { Console.WriteLine("HijriAdjutment = {0}, Exception: {1} ", adjustment, ex.Message); } } static void Main(string[] args) { TestHijriAdjustment(-2); // Prints Year = 0!! Why doesn't it throw an exception? TestHijriAdjustment(-1); // Throws exception TestHijriAdjustment(0); // Prints Year = 1 TestHijriAdjustment(1); // Prints Year = 1 TestHijriAdjustment(2); // Prints Year = 1 } Now the reason I want minimum supported date t

Problem in debugging a class library


When I try to debug a class library I am getting an warning message "Unable to automatically step into the server. Connecting to the server machine 'xxxx.xxx' failed. The debugger cannot connect to the remote computer. This may be because the remote computer does not exist or firewall may be preventing communication to the remote computer. Please see help for assistance."

After getting this message my application shows the result set from the web service. I am not trying to debug the web service application, but trying to debug my code which is in another project in the same solution. Also I have added the project reference from my test application not the dll reference. I've checked the windows firewall and added exception for port 80 also.

Any help in this regard will be greatly appreciated.




Problem canceling asynchronous method



I want to canceling an asynchronous method.

How can me it?


public IAsyncResult BeginGetAllUsersCount(object sender, EventArgs args, AsyncCallback callback, object state)
       //Canceling asynchronous operation
     return AdapterUser.BeginGetAllUsersCount(callback);

   public void EndGetAllUsersCount(IAsyncResult asyncResult)
     _totalRowsCount = AdapterUser.EndGetAllUsersCount(asyncResult);




C#NET2008 FrmMain using DELEGATE CLASS Method



Hullo Good Guys,


I am back here seeking help. Please Help me.


Here us the description of what I was ihstructed to do by the System Analyst.


Create DELEGATE Class to perform Mortgage computation and return the result back to the calling FrmMortgage.cs. Apparently my coding are not working as I am not familiar with DELEGATE Class


Here are the Erro

Calling a static method in a static class from a base class.


I have the following static class and method:

public static class GenericList


      public static List<DocumentElement> PopulateGenericList()



What is the syntax to call the PopulteGenericList() method from a base class?



ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend