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

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

preferred method to choose where to place if condition for query

Posted By:      Posted Date: August 31, 2010    Points: 0   Category :ASP.Net
I have a design problem I could use some help determining how to code this problem.   I have a table with 3 fields, catCode, startDate and endDate. I am having trouble deciding how to query my DB based on the following...   By default a gridview will return all records that match the catCode selected from a dropdown list.   If the user checks a check box, only records are returned where.... startDate <= today AND endDate >= today   How can I apply the If condition to compare when the check box is selected? I used the wizard to build the select statment for the gridview, but I can switch that to a SP if that makes life easier.   Thanks for any and all help and suggestions.  

View Complete Post

More Related Resource Links

condition Select query

Hi All.Greetings.I have 1 table.Table 1ID | Name  | Sex       |  DateofBirth1   | abc    | Female  | 19802   |abc2   | Female  |20083   |abc3   |Male       |19854   |abc4   |Male      | 2009I want to see if age is greater then 3 year it will adult girl or adult boy. and If age is less then 3 year then it will be child girl or child boy.I have Output like thenName | Sex         |abc    | Adult girl |abc2  | child girl  |abc4  | child boy | etc.....How to write condition query to get my result.Thanks in Advance.

place a condition in the RAISERROR

i have a raiserror statement ansd i need to place a condition to not raise the error when specific records exist in the table.   BEGIN RAISERROR( 'TABLE1 records do not exist in refTABLE. Please verify with John.',16,1) END this works ***************************************************** BEGIN iif ((TABLE.TYP_ID) NOT IN (10,20,30,40)) THEN RAISERROR( 'TABLE1 records do not exist in refTABLE. Please verify with John.',16,1) END I need the correct syntax....)

Field method missing with LINQ query

H, I want to access the data from datatable object. When i trying to get the fieldslist usng "Field" method. But I could not find the method with my table object.  Eventhoguh i forcibly write a method and trying to access the fields, It is giving the below error for the first join in query. Rest of the lines are fine. What is the reason behind it. The errro: "Error 2 'LINQ2DB.SP_VS_OP' does not contain a definition for 'Field' and the best extension method overload 'System.Data.DataRowExtensions.Field<T>(System.Data.DataRow, string)' has some invalid arguments" What is the meaningof the error. Shall i do any other changes in the query line?                         var QueryChnl = from oSPOP in SPOP.AsEnumerable()                        join oDiscChannel in DiscChannel.AsEnumerable() on oSPOP.Field<int>("spid") equals oDiscChannel.Field<int>("SPID")                        join oChannel in Channel.AsEnumerable() on oDiscChannel.Field<in

Sharepoint 2010 FullTextSqlQuery query problem with where condition

Hello, i´m developing a webpart under Sharepoint 2010, i need to launch some different query´s to filter data but i´m having problems. First of all, i launch this query and i get all the users; SELECT PreferredName, LastName, Department, OfficeNumber, JobTitle, WorkEmail, PictureUrl FROM Scope() WHERE ("scope" = 'Personas') ORDER BY "Rank" DESC with that results i fill different dropdownlist with each of the columns, then I can filter for each column. For example: I filter by PreferredName, Lastname or WorkEmail, with this query SELECT PreferredName, LastName, Department, OfficeNumber, JobTitle, WorkEmail, PictureUrl FROM Scope() WHERE ("scope" = 'Personas') AND (("LastName" Like '%MOSS%')) ORDER BY "Rank" DESC But when i try to use the columns Department, OfficeNumber and Jobtitle every query returns 0 rows. SELECT PreferredName, LastName, Department, OfficeNumber, JobTitle, WorkEmail, PictureUrl FROM Scope() WHERE ("scope" = 'Personas') AND (("Department" Like '%Dirección%')) ORDER BY "Rank" DESC The main thing is if i get all the data i see that these columns (officeNumber, Jobtitle, Department) are not empty. Some of them have values some of them don´t. All the columns have the property "Reduce storage recquirement for text propert

The error is: Method 'ProxyNamespace.ServiceNow_GetMetric.query' not found..


Hi guys -

I am working on a project where I need to call a WebService Method via the WebService Task in SSIS, and I am getting below error . The content of the WDSL file is also attached. Has anyone got this kind of error? I use BIDS with SQL Service 2008/Windows XP professional.

Thanks for your help


"[Web Service Task] Error: An error occurred with the following error message: Microsoft.SqlServer.Dts.Tasks.WebServiceTask.WebserviceTaskException:
Could not execute the Web method. The error is: Method 'ProxyNamespace.ServiceNow_GetMetric.query' not found..

   at Microsoft.SqlServer.Dts.Tasks.WebServiceTask.WebMethodInvokerProxy.InvokeMethod(DTSWebMethodInfo methodInfo, String serviceName, Object connection)
   at Microsoft.SqlServer.Dts.Tasks.WebServiceTask.WebServiceTaskUtil.Invoke(DTSWebMethodInfo methodInfo, String serviceName, Object connection, VariableDispenser taskVariableDispenser)
   at Microsoft.SqlServer.Dts.Tasks.WebServiceTask.WebServiceTask.executeThread()". 


WDSL File content:

<?xml version="1.0" encoding="UTF-8"?>

<wsdl:definitions targetNamespace="http://www.service-now.com" xmlns:tns="http:

Query a XML column using the nodes method


Trying to learn xml, excuse my ignorance here....

I was able to write this query to shred the xml and get all the list_id's for just one row, I copied the xmldata and assigned it to a variable and it worked just fine.

declare @xmlData xml
set @xmlData = '<order tab_id="74" open="N" sorder_id="166" status="v2.0{1,2,3,4}">
  <list p_id="0" p_seq="0" list_id="10762" open="N" status="">
    <element elem_id="201041" elem_seq="14" click_id="1">
      <list p_id="10762" p_seq="14" list_id="10763" open="N" status="">
        <element elem_id="201054" elem_seq="284" click_id="2">
          <list p_id="10763" p_seq="284" list_id="10764" open="N" status="">
            <element elem_id="201376" elem_seq="669" click_id="3" />

Webmatrix.Data.Database.Query() method return type


I'm using the Webmatrix.Data.Database.Query method to return a result set in the following form

var myResult = db.Query("Select * from mytable");

How do you cast myResult to get the count of records returned? I'd like to do something like


Query condition with NOT IN operator t-sql 2005?


Hi I have below T-SQL 2005 query....

FROM MyOrderTable a
WHERE (OrderID, OrderDate, DespatchDate) NOT IN (
                      SELECT OrderID,OrderDate,MAX(DespatchDate) as DespatchDateMax
                       FROM MyOrderTable
                      GROUP BY OrderID,OrderDate
                      HAVING COUNT(*) > 1 )

When I run query it giving me WHERE condition error. Please can you post alternative T-SQL 2005 query for my above example? Thanks...

dynamically provide xpath condition for exist() method


Consider the sample


-- Element-centered XML

SET @data = N'<data> <customer> <id>1</id> <name>Allied Industries</name> </customer> <customer> <id>2</id> <name>Trades International</name> </customer> </data>';

-- Select only customer which id equals 2 using the exist() method

SELECT T.customer.value('(id)[1]', 'INT') AS customer_id, T.customer.value('(name)[1]', 'VARCHAR(20)') AS customer_name FROM @data.nodes('data/customer') AS T(customer) WHERE T.customer.exist('id/text()[. = "2"]') = 1;

In the above query, I need to provide the condition 'id/text()[. = "2"]' to exist method dynamically More generally, I can say, I have XML data and need to check different clauses on the xml data.

please help out. Thanks

Update Query ? Incorrect use of the xml data type method 'modify'. A non-mutator method is expecte


I have a column of ntext da


ta type and NOT XML. It stores all xml data. I need to update xml node in the records. It throws an error saying "Incorrect use of the xml data type method 'modify'. A non-mutator method is expected in this context."

 begin transaction
declare @Cps_Id int;
set @Cps_Id = 236;
declare @Cps_Message nvarchar(1024);
set @Cps_Message = 'updating cpsia message with smoking';

update table_name
set column_name = CONVERT(xml,column_name).modify('replace value of (/root/ProductInformation/CPSIA/CpsiaDetails/Item[CpsiaId=sql:variable("@Cps_Id")]/CpsiaMessage/text())[1] with sql:variable("@Cps_Message")')
WHERE Convert(xml,column_name).exist('/root/ProductInformation/CPSIA/CpsiaDetails/Item[CpsiaId=sql:variable("@Cps_Id")]')=1


Sample XML:

<strong><root> <ProductInformation> <Name> Truck with Battery Charger</Name> <Description>Fr.</Description> <CPSIA> <CpsiaDetails> <Item> <CpsiaId>456</CpsiaId> <CpsiaMessage>waring</CpsiaMessage> </Item> <Item> <CpsiaId>236</CpsiaId> <CpsiaMessage>to health</CpsiaMessage> </Item&

Thinking about new C# method prototypes: object as dictionary

I recently had to write a small Flickr API. I know many .Net API for Flickr already exist but I needed one for a Silverlight application. Whatever, it's only about building some querystrings so I did it by myself. It's been an opportunity to think again about a classical question: how to pass parameters to a method ?

Imagine you have a generic method to call some Flickr functions.

MS SQL Server: Search All Tables, Columns & Rows For Data or Keyword Query

If you need to search your entire database for specific data, this query will come in handy.

So when a client needs a custom report or some sort of custom development using Great Plains, most of the time I will have to track down the data in the system by running this query and find the table(s) it is in.

How to Encrypt Query String Parameters in ASP.NET

Encrypt Query String Parameters in ASP.NET.u can send secure data one page another page u can also use query string to encrypt

Content Query Web Part missing in SharePoint 2010

If you don't see content query web part listed in the web parts list, this is because you have not enabled "Search Server Web Parts" feature in site collection features. Enable this feature and content query web part will show in the list of web parts.

Sys.Net.WebServiceFailedException: The server method '' failed with the following error:



Let's say we have 2 time consuming functions, aaa and aaa1 inside a aspx page.

        public static string aaa(int i)
            return i.ToString();

        public static string aaa1(int i)
            return i.ToString();



        <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
        <span id="displayspan"></span>
        <br />
        <input type="button" value=

Jscript error: Object does not support property or method


 Hi, i have little knowledge on javascript but i need to use this code get from somewhere for a jquery to work.

I face this "Jscript runtime error: Object does not support property or method" whenever im trying to run this page.

In my experience, im get this error msg 9 out of 10 times i use javascript in my system.

Im using Microsoft Visual web developer 2008, i wonder if this is related to my problem, i not sure there is anything i need to add as reference or update anything.

But anyway, in short, i just couldn't use javascript code when using this development tool because of this sort of error.

Anyway, it happen that last time i tried use the same type of jquery code in another project and it seems to work well without an error.

But now when im try to use it again in this recent project i created, it come out with this error and i have no idea how to solve it even look through google and this forum.

It doesn't really seems like its the code problem itself although im not sure, because any javascript code just couldn't work.

So below is my code that i need to use.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" ></script>
<script type="text/javascript" src=&quo

Using CreateNewUserWizard SendingMail method to email me, not applicatnt.


I have staff area of my site I am protecting with forms authentication using c# and .Net 4.0. What I want to do is let the staff members register on the site but instead of the confermation email being sent to them I want it sent to me so I can go in and approve it. I have been trying to use the SendingMail method  but can not figure out how to get it to email me instead of the person that registered. I have searched around this site and find many topics on the SendingMail method but none seem to properly address my issue. Can anyone help me out?

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