.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

Class Not returning accurate values

Posted By:      Posted Date: October 15, 2010    Points: 0   Category :ASP.Net

Hello guys,

Please can anyone look at this class and say why it's just returning just the first row in the second query, the issue is that the

Salary is showing the right value when debugging, but when deployed to IIS it's just returning the 1st row

Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Data
Imports System.Linq
Imports Telerik.Web.UI
Imports EMPTaxesLINQ
Namespace EmployeeTaxes.DataLoad
    Public Class GetData
        Public Shared Function GetSalary(ByVal sEmployeeID, ByVal Sdate, ByVal Edate) As Decimal

            Dim sMonth, eMonth, sYear, sEMPID, AbsenceTotal, SalaryType As Integer
            Dim DailyRate As Decimal
            Dim db As New EMPTaxesLINQ.EMPDCDataContext()
            Dim salary As Decimal = 0
            sEMPID = Convert.ToInt32(sEmployeeID)
            'get salary type

View Complete Post

More Related Resource Links

Control Values When Returning to Page


Why do controls value not persist when returning to a page (e.g. via browser back button)?  If I set control values without utilizing a post back the controls will maintain their last value when I return to the page.  If I set a control value and then call a post back, the control value is reset to the default value when returning.

I have many pages with a gridview, and a textbox which is used to filter the gridview contents.  I set the filter textbox, filter the gridview (postback), go to another page, and when I return to the gridview page (via back button), my filter textbox is reset empty, and the gridview is the original (unfiltered) data.

What concept am I missing here?

Thanks in advance...

Gridview RowCommand Event returning null values

HiI'm trying to retreive values entered by users in the textboxes in the footer of the gridview and insert these values into another sql table.My code is as follows :-protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e)    {       if(e.CommandName.Equals("addnew"))       {                       TextBox t1 = (TextBox)GridView2.FooterRow.FindControl("tfrm");            string frm = t1.Text;            TextBox t2 = (TextBox)GridView2.FooterRow.FindControl("tsub");            string sub = t2.Text;            string cmd = "insert into suggestions values('" + frm + "','" + sub + "','c','c')";            con.Open();            SqlCommand com = new SqlCommand(cmd,con);            int a = com.ExecuteNonQuery();&n

WCF service returning old values

Hi. I am developing an application with WCF services. The basic functionaloty of a screen is to provide an entry screen to add particular entity. Once save even fired It will save the data to the database and call the bind method to bind into the grid by refreshing the latest data. When I am running the site from my source (Visual Studio) , it works perfectly. When the client calls method to fetch the data the WCF service, it returns latest (added) data. But the issue comes in the server when it works with IIS. I deployed the code in the server, once the data added I am getting the old data only. But after two refresh I am getting the latest data. Could you please let me know what required to be done to get the latest record. Many Thank, Kelvin Kumar

Process.Modules Not Returning Correct Values in x64

Hey All!   Here is my problem, when i use the following code:   Process hProcess = (.....); foreach (ProcessModule m in hh.Modules) { Console.WriteLine(m.ModuleName + " - " + m.BaseAddress); }   On a 32bits machine I get like 20 different values, those are the ones I use further in my program. However in a 64bits machine I only get: myexe.exe, ntdll.dll, wow64.dll, wow64win.dll and wow64cpu.dll.   I also tried EnumProcessModules, but got the same result.   How may I get the correct values I need?   My .NET exe is compiled at 32bits and the target process is also 32bits.   Thanks, Best Regards, Mywk

Custom membership provider not returning values from my web.config


I created a custom membership provider in my ASP.NET 4.0 web site, stored  in App_Code, and referenced in my web.config.

However, it doesn't appear to be pulling values out of web.config during initialization.

The code was taken from http://www.asp.net/general/videos/how-do-i-create-a-custom-membership-provider, and the only modifications were changing "connectionStringName" here to the name of my connection string:

    Dim ConnectionStringSettings As ConnectionStringSettings = _

The connection string always comes back as nothing in this line:

    If ConnectionStringSettings Is Nothing OrElse ConnectionStringSettings.ConnectionString.Trim() = String.Empty Then
      Throw New ProviderException("Connection string cannot be blank.")
    End If

No matter what I change the password format to in web.config, the default value here is always used:

    Dim temp_format As String = config("passwordFormat")
    If temp_format Is Nothing Then
      temp_format = "Has

spgridview RowDataBound event returning cell values as empty


i am working with SPGridView to display Announcements. User should be able to edit his own created Announcements.Remaining Items shouldnt be having edit option.

i created SPGridView Columns :

                SPBoundField Title = new SPBoundField();
                Title.HeaderText = "Title";
                Title.HeaderStyle.Font.Bold = true;
                Title.DataField = "Title";

                SPBoundField Description = new SPBoundField();
                Description.HeaderText = "Description";
                Description.DataField = "Description";


Questions about creating a class that returns multiple values


Hey all,

I am a little stumped, been trying to find some references to this but I am coming up with more confusion than anything else.lol

Here is my scenario using asp.net and VB.

I have an aspx page with about 10 label controls on it and a couple of image controls. Their data will be all populated dynamically by a single URL query string that is passed to a 3rd party url query string that retrieves an xml document with all of the information on it. I am currently just using the page load event and from that I can get everything I need and populate the page elements no problem with all of the code existing on the aspx.vb page.

However I thought for this project as I go forward I would like to create a vb class that handles all of the work instead of using the code behind page which has become quit convoluted.

I am not completely new to creating classes, I've done them before, and some pretty complex however this one is new due to the fact that I want to return multiple values.

So my thought is to approach it this way.

1.       On the page load event I grab the URL query string, and pass it to the vb class to begin the process.

2.       In the class I create a function that loads the xml document into memory.

3.     &n

Assign values to base class properties


In my controller have a FormViewModel which inherits from a domain class declared in dbml.  In the constructor of the FormViewModel I want to do a shorthand assignment to the inherited class properties with the passed in object (ie thisPerson) without iterating through each property of the inherited class and assigning its value with corresponding property in the passing in object. Should I use super, base, this, or something else?

public MyFormViewModel: Person
  public SelectList Cities {get; private set;}
  public SelectList State {get; private set;}

  public MyFormViewModel(){}

  public MyFormViewModel(Person thisPerson) 

        this = thisPerson; 
     //or super = thisPerson;
     //base = thisPerson;


select returning a list of values seperated by commas


I’m performing a select statement that returns the primary key of all the records matching  certain criteria. Instead of the returned set having  a row for each record returned, I want to just return just  one record that consists of a text field containing all the primary keys separated by commas.


For example:

Select personID from people

Where age < 45


Instead of:

Inserting Property values of class into ParamArray parameters as object()


Hi All,

Using the properties as defined in a class, how about can I put them into the ParamArray parameters argument of my function.

The code as follows:

Public Class MyObject

   Public Property Prop1 as string

   Public Property Prop2 as integer

   Public Property Prop3 as Boolean

   Public Sub  AddNewMyObject

        MsSQL_ExecuteNonQuery("StoredProc_AddNewMyObject", ________________?)

   End Sub

End Class

Protected Function MsSQL_ExecuteNonQuery(ByVal storedProc as string, ByVal ParamArray parameters as object())

'Some Code here.

End Function

Please kindly help and advice.

Thank you in advance.

Warmest Regards,


Service returning Object fails when object is complex class


Hi. I have created a WPF client and a self-hosted WCF Service based on an interface, in wich alle methods returns a standard response class. An example of one such method definition is:

Response CreateAccount(AccountCreationParams accountParams);


The response object is defined as:



public class Response



public string ResponseText;


public bool CompletedSuccesfully;



SSIS_SQL2005_Sharepoint ListSource Adapter_DT_NTEXT values returning NULL on extract/import


Hello.  Please HELP!!!!  I've been trying to figure this out for a few days.

I am using the SSIS SharepointAdapters for 2005.  When I pull data from my sharepoint site, for fileds that are choice fields in sharepoint are a datatype of DT_NTEXT w/4000 characters.  The only thing in these fields is "PASS" " "FAIL" and one filed has "QA Review Completed".  When the data is imported into SQL these fields eiher show NULL or <Long Text>.  I am using the combination of the Derived Column and Data Conversion to change the Datatype of these fields from DT_NTEXT since no output will accept this datatype.  I've tried exporting to Excel, Access and Flat files only to get same results.  What I don't understand is if I import the data from Sharepoint to Access or Sharepont to Excel using Sharepoint and not SSIS, I get the data that is in the field(s).

I've searched all over the internet and have not found where anyone has had the same issue which I find to be odd - I can't be the only one.  I hope I'mnot.




Selecting Returning values from sql database in asp.net 2.0 codebehind and c#



 Is there a way of selecting returned values from a call to an sql database in the code behind? For example assume that I used the following to select values from a table called Products;


              SELECT  Price, Qty, Numbersold FROM Products


How can I now get the returned values e.g.  Price  in the c# codebehind and display it in a textbox? I know that in the asp markup that I can use EVAL and Bind statements to do this for example I can do Eval("Price")  but is there a way of getting any of the selected values (Price, Qty or Numbersold)  in the codebehind?

I know that I can use three separate select statements and  make three separate calls to return each value and then do something like the following

Price = Convert.ToInt32(myCommand.ExecuteScalar());


But using three separate calls is very inefficient!






Returning identity values within an XML document




Suppose that I have 2 tables that represent a Master-Detail relationship: Order(#ID_Order int) and OrderLines(#ID_Line int, *ID_Order int). Both primary keys are identity columns, and the rest of the columns are omitted for clarity. This 2 tables are filled by using a client application, a classic form that has a header section for the Master and a grid for the Detail.


In the old days, I would use an stored procedure (SP_Save_Order) in order to save into the Order table, which returns the identity value for the #ID_Order column and then iterate for each Line in the form, invoking another stored procedure (SP_Save_OrderLine) using the returned #ID_Order value and returning the new identities for #ID_Line as well. So, multiple round trips are made. Those stored procedures have an IF statement which checks if the Order/OrderLine exists, if they don't an INSERT is made -an UPDATE otherwise. That's why the importance of returning the Identity values to the client application: A new document can be saved at a first instance -but modified later.


Now, I have learned that by using the XML datatype and XQuery I can save in just one trip the Order and the OrderLines (if the order is new).  Consider the following simple docum

Class Properties Not Reflecting Their Changed Values


 I am using a class to track if a user cleared their personal information found within some text boxes on a form. In the button click event to clear the text boxes I am creating a new object to the class and assigning true to one property value. Sounds simple until I try and submit the form with a different button, and create a another object reference that I use in an IF statement to check the property value for true. Every time the statement fails because the value being returned from the getter in my class is false.

This is the class:

Public Class FormStateClass
    'property holds true or false 
    'based on if the user clears the populated form values.
    'True = Form was cleared
    'False = Form was not cleared

    Private _test As Boolean
    Public Property FormState As Boolean
            Return _test
        End Get
        Set(ByVal value As Boolean)
            _test = value
        End Set
    End Property

End Class

This is the code I am using to set the property to true:

Dim thisForm = New FormStateClass With {.FormState = True}

I've also tried these statements:

Check the if SSAS Roles property is used in excel connection string before returning the values



We are using Excel 2007 to connect to SSAS cubes. We have many roles for a user and all having different permission including different VISUAL TOTAL setting. We want to restrict the user so that he cannot see anything if he is not using the ROLES property in the excel connection string.

At the run time I want to know if the user who is using excel has used ROLES property or not.

Any help will be appreciated

Mr myName

Class Diagrams

Class diagrams show the static structure of the systems. Classes define the properties of the objects which belong to them. These include:

Attributes - (second container) the data properties of the classes including type, default value and constraints.
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