.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

Return no result

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

I have a query like below.  It returns 25 records without the commented line in bold.  The 25 records all have SiteId of 823.  the currentSiteId is set via a property of this class.  The SiteId is nullable short (short?) in the SQL Server table (smallint null). The query returns no record when the line in bold is uncommented.  I tried using t.SiteId.HasValue & t.SiteId.Value.Equals(currentSiteID). I also tried t.SiteId.HasValue & t.SiteId == currentSiteID.  All of them return no record. Plase help.  Thanks.

public class MyRepository : MyApp.Models.IRepository {

        short currentSiteID;

        public short SiteID {
            set { currentSiteID = value; }

        public IQueryable<MyApp.Models.Account> FocusStudy()
            return (from t in db.Accounts
                    where (

View Complete Post

More Related Resource Links

Linq to sql does not return appropriate multiple result sets with "If exists" conditions in the stor


Hello All,

I have a stored proc that returns 4 resultsets, they are in the format.

ALTER PROCEDURE [dbo].[pGetManagerEmployeeSummaryDummy]

    @ManagerStaffID int,
    @PeriodID int



IF EXISTS (select 1 from dbo.temployee e
    inner join dbo.temployeedetail ed
        on e.staffindividualid = ed.staffindividualid
        and ed.periodid = @PeriodID  
    inner join Incentive.tRole r
        on rm.IncentiveRoleID = r.RoleID
    where ed.ManagerIndividualStaffID = @ManagerStaffID
    AND r.RoleID = 1) --Closer
        SELECT e.StaffIndividualID, e.LastName, e.FirstName, r.RoleName, e.xname, e.yname

from dbo.temployee e

inner join dbo.temployeedetail ed
            on e.staffindividualid = ed.staffindividualid
            and ed.periodid = @PeriodID

where ed.ManagerIndividualStaffID = @ManagerStaffID

Check if Linq query return result

HelloI have Linq query likeDim Prood= (From p InProdutcts _                                          where p.ProductID="InputInteger"                                                         ..... ) .SingleOrDefaultI could Use Count if I Use .ToList Instead of .SingleOrDefault , But now that I use 'SingleOrDefault', how Could I find if Prod contains any record or it's Empty.

Full Text Search Return no Result while "Like" does

Someone pls look at the picture and help me I tried Restart the serviceI tried restart the server But the number of row affected is still zero :(

calling web service from SSIS return result as null



I got this result

<Result>The result is null. Either the result is null or the Web method returns void.</Result> 
 when I calling web service from SSIS. I setup HTTP connection and tested without any problem; download WSDL without any problem; I did exactly as the link: http://msdn.microsoft.com/en-us/library/ms181267.aspx. From input editor, I selected service and method. For the chosen method, there will be 3 variables (1 input parameter, 2 output parameters). For the input variable, I defined the package variable as string, and copied XML content to the variable as the value. I will select this defined package variable as the input parameter. I then moved to defined output file.
 When I run the simple package, I will get the output file as result as above. What is wron

how to return linq result to dataset



        i have one class which return dataset  as a returnvalue. i write stored procedure and calling that stored procedure uding linq thsts work but after calling i want linq result must store in dataset and then i return that dataset like

 public DataSet GetData(int id)
        DataSet dsInc = new DataSet();
        AdministratorDataContext db = new AdministratorDataContext();

        var result = db.StoredProcedure1(id);

return dsInc


so i want to return dsInc i.e dataset but how i stored that result in my dataset. Reply me ASAp.

Webservice Return as List Need Help to set result as List


Hi all,

I have webservice which return list of class.

    public List<Myclass> MyMethod(String ID)


//some operetions is done


I am calling this service and I want to get result as list.

its accessable myclass (public) ad myMethod Public

I tried

List<myservice.Myclass> myserv=new List<myservice.Myclass>();

I want to result to bing on above variable.

myservice.NewWebServiceService newme = new dene.NewWebServiceService();


I gives an error such as

Error    1    Cannot implicitly convert type 'WindowsApplication1.myservice.Myclass[]' to 'System.Collections.Generic.List<WindowsApplication1.myservice.Myclass>'    C:\Documents and Settings\Mikail\Belgelerim\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Form1.cs    24    20    WindowsApplication1

Thanks for any reply.

How to return SQL result set?


Hi Folks,

This should be simple...
I want to know how to return an SQL result set in a WCF service...

I am familiar with how to query a DB into an SQL Data Adapter and then binding the Query result to a DataGrid etc...
But how to send out the SQL query result as XML or Json for WebService needs.... Can I 'bind' my result set to XML...?!!!!
From my reseach it mentions LINQ, but it seems like too much re-inventing the wheel for something seemingly easy....

- Andy

ListView DataPager with SQL-Statements that already return only paged data.



As far as I understand the ListView-Control and the DataPager-Control, they work like this: The ListView gets its datarows from its data source, then the DataPager causes the ListView to display only a subset of those rows.

So what, when I want to use custom databinding for the ListView, that *already* gets the certain subset from SQL-Server (for better performance). Can I and how can I use the DataPager then?

Thanx, S.

Need Syntax To Make Results of LINQ Union Return Non-Generic Type



I have the below SQL which works just fine:

SELECT     Message, CreateDate, AccountId, AlertTypeId
FROM       dbo.Alerts
SELECT     TOP (100) PERCENT Status, CreateDate, AccountId,
                          (SELECT     10 AS Expr1) AS AlertTypeId
FROM         dbo.StatusUpdates
WHERE AccountId = PassedInParameter

I have been going about trying to convert the above into a LINQ method and am having problems with return types.
As the above SQL illustrates, I am querying two distinct LINQ tables - Alerts and StatusUpdates -
and then attempting to perform a Union on them. In order to do the union in LINQ, I have to have agreeing types. So, I
am using "var" to make the results of "alerts" and "updates" generic before the union.  

public IList GetStatusUpdatesAsAlertsByAccountId<T>(Int32 accountId)
            using (WorkbookDataContext dc = _conn.GetCont

XMLHTTP.ResponseText return unexecuted code?


I have a simple asp with the following code.  When I access this page directly (via browser) everything works fine:  the xml object shows up fine.  When I call this page via VBA (excel), the ResponseText method of the 

XMLHTTP object returns the below code unexecuted.  Anybody knows what's going on?  thanks.

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> <% Response.Buffer = True Response.ContentType = "text/xml" Dim oDataXML As Object 'Custom Data XML passed in by caller. On Error Resume Next 'Load the XML passed into the request. oDataXML = Server.CreateObject("Microsoft.XMLDOM") oDataXML.Load(Request) Dim sResult As String sResult = "<?xml version=""1.0""?>" sResult = sResult & "<OrderProcessed>" sResult = sResult & "<Status>test</Status>" sResult = sResult & "<OrderID>111</OrderID>" sResult = sResult & "</OrderProcessed>" Response.Write(sResult) Response.End() %>

Active Directory and .NET: paging the search result

Hi everybody!

I have a question about Active Directory in .NET
For my project I need to fetch results from Active Directory search page by page, because later I would need to bind it to the pageable DataGrid.

I tried to use .NET library DirectoryServices for that, but paging provided by this library is transparent to the user and is used only to increase the efficiency of searching, when results are too big. I.e. I cannot tell the DirectorySearcher to give me first page, then the next or previous page, it returns me all resulting pages in one bundle.

However, what I need is to explicitely get page after page directly from the AD searcher and to be able to go at least one page forward or backward.

The solution with copying all results to the DataBase and then do the paging is not accepeted by the clent, since it is too inefficient. And since it's a Web app, I cannot keep results in memory either.

I found some hints about COM Interface, but I could not find good and detailed examples or explanations. I aslo found this line of code: DirectoryServices.Interop.IDirectorySearch.ExecuteSearch(), but I don't know which libraries should i add to be able to compile this code.

If somebody could help me out with that problem, any suggestion is welcome, 'cause this issue is eating me alive :)

Thank you!

Posting data to ASMX and return Object for jQuery


I am using fluent NHibernate with WebForms and I am trying to build a page where I allow a user to post a status update on their profile page and I a using a .asmx WebService to post the data to the database and then returnig a StatusUpdate instance to the page to be used by jQuery. I have a couple problems.

1) First off when I return a string from the WebService(i was testing) the textbox where the user enters their status doesnt empty the contents. And since the page doesnt refresh even if I manally clear out the textbox and put in something else, it still posts the previous status to the database again. How do I fix this?

2) Secondly, when I return the StatusUpdate Object from the Webservice I cant the results to display anything. Like I sad, Im using jQuery to make an AJX call to the WebService.

Here is my code:

User Profile Page:

Status: <asp:Label ID="status" runat="server"></asp:Label><span style="font-size:.7em;"><asp:Label ID="statustime" runat="server"></asp:Label></span><br />
<textarea id="statusBox" rows="3" cols="40"></textarea><br />
<input type="button" value="Update Status" onclick="SetStatus(); return false;

Return of the Rich Client: Code Access Security and Distribution Features in .NET Enhance Client-Sid


Rich clients employ many of the features and conveniences of the operating system they run on, and the list of these features has been growing since the dawn of the PC. But as apps have migrated to the Web, the trend towards increasing client-side functionality has ground to a virtual halt. There are several reasons for this; chief among them are security and deployment problems. But that's all about to change. With the .NET Framework, you can participate in building the distributable rich client of the future. In this article, the author enumerates the pertinent features of .NET that will allow you to build safe, easily deployable controls. The features discussed include managed code, code access security, versioning control, Windows Forms classes, and isolation.

Jason Clark

MSDN Magazine June 2002

SQL and XML: Use XML to Invoke and Return Stored Procedures Over the Web


Front-end developers frequently want to add functionality to the presentation tier of an n-tier architecture, but such requests can require changes on all tiers just to get the data and present it. This process can be made easier and more flexible by using SQL Server stored procedures to automate the delivery of data in XML format from the database to the front-end components. In the component presented here, stored procedures are invoked by XML strings, XML is returned, converted using XSL, and presented to the client in HTML. The technique supports rapid changes yet doesn't sacrifice the n-tier approach. This approach can be used with either SQL Server 7.0 or SQL Server 2000.

Dave Grundgeiger, Anson Goldade, and Varon Fugman

MSDN Magazine August 2001

linq and max, if return null return error


hi there
i have this query :

var result2 = (from TH in DB.Threshold
                          where TH.ProductSKUID == int.Parse(HID_ProductSKUID.Value)
                          select TH.ThresholdID).Max();

the problem is that if this query does not find any items, return null, so thow exception
how can i do to return 0??

insufficient result space to convert uniqueidentifier value to char


Hi guys,

       Look, I've been trying to insert new values while I create a new user with a createuserwizard, but I've been getting this error over and over again:

"insufficient result space to convert uniqueidentifier value to char"

       The code that does it is the following:

  protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
TextBox UserNameTextBox = (TextBox)CreateUserWizardStep2.ContentTemplateContainer.FindControl("UserName");

SqlDataSource DataSource = (SqlDataSource)CreateUserWizardStep2.ContentTemplateContainer.FindControl("InsertExtraInfo");

MembershipUser User = Membership.GetUser(UserNameTextBox.Text);

object UserGUID = User.ProviderUserKey;

DataSource.InsertParameters.Add("UserId", UserGUID.ToString());


      But when I debug, the error is thrown before reaching the previous code, so I suppose the error is in the SqlDataSource, look:

      <asp:SqlDataSource ID="InsertExtraInfo" runat="server" Co

reading the result of a web service (XML)


Hi all,

I registered for a service that returns me the geolocation of the visitor and i process it in my exe application (c#).

But i dont know how to read that data in cs?

Here is the link that i send : 


and returning page content ;  

<?xml version="1.0" encoding="UTF-8" ?>
  <provider>Turk Telekom</provider>
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