DataSource Controls :: Select Distinct With Where Clause Don't Work?

May 2, 2010

I'm using asp.net login on a SQL Database.

I have 12 users in my User tabel - one of the user I don't want to have in my select (the user is an admin).

I tried this:

[Code]....

I also tried:

WHERE (dbo.aspnet_Roles.RoleName <> 'Administrators')

Both time it took the user into the table....

If I instead try this

WHERE (dbo.aspnet_Roles.RoleName = 'Administrators')

I get only one row (as expected).

What is wrong with the above sql statement - why can't I get 11 users and not them all (12 users)?

View 3 Replies


Similar Messages:

DataSource Controls :: Select Distinct Field In LinqDataSource

Jun 3, 2010

<
asp:LinqDataSource
ID="LinqDataSourceSM"
runat="server"
ContextTypeName="SalesIntranetSolution.DataClasses.salesIntranetDataClassesDataContext"
OrderBy="reportTo"
Select="new (reportTo)"
TableName="cubeSalesRepRollups">
</asp:LinqDataSource>

Does somebody know how I can modify this LinqDataSource to select distinct records only?

View 1 Replies

DataSource Controls :: How To Select Multiple Columns With Distinct Key Word

Jan 2, 2010

there are multiple rows with same SubContact_No and with same value of some columns. for a single column I am firing query like

Select distinct (Financial_Status) from mtblSub_Contract where SubContract_No=@SubContract_No";

it's working fine.... (it's ok with a Single column)

But Now I need multiple columns value so how to query for this.

Select distinct (Financial_Status, colums2, column3) from mtblSub_Contract where SubContract_No=@SubContract_No"; is not working

So how to do that.

View 5 Replies

Select Distinct And Include Non-distinct Columns?

Apr 20, 2010

I would like to select a distinct query based on three fields and display the rest of the fields. For example,

I have firstname, lastname, address, city, state and zip, but I only want to use the distinct on these fields first and last name. However when i use the distinct function I get a distinct on all the selected rows. I just want to distinct firstname and lastname and display the other fields. for example,

Mary Smith New York
Mary Smithy New York
Mary Smith Maine

I would like the result to be:

Mary Smith New York
Mary Smithy New York

I don't care about Mary Smith Maine, because i am only using the distinct for "Mary Smith" firstname and last name and showing the city.

View 15 Replies

Forms Data Controls :: Clause On UserID Together With Other Parameters Does Not Work?

May 4, 2010

Iīm a newbie at .NET and Iīm trying to solve how to run a datagrid with parameters. I know how to do where clauses with controls and today I managed to solve how to have a where clause at UserID within a SelectingEvent.BUT, I canīt run them both in the same time. I want to run a query based on the month in a dropdownlist and the UserID. Each one individually works.Why canīt this be done? Is the onselect statement ignoring the other parameter? I donīt get any errors.The ASPX (in VB.net) code is:

<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="IndividuellBonus.aspx.vb" Inherits="Income_IndividuellBonus" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">

[code]...

View 4 Replies

DataSource Controls :: Select Query Doesn't Work When Data Is Present In Arabic MS Sql 2005

Jan 26, 2010

This query does not return any record

[code]....

View 3 Replies

SQL Server :: Select Distinct From Another Select?

Feb 26, 2011

how to write a select distinct column1 from another select ?

i mean SELECT distinct column1 from (SELECT column1,column2,column3 where column1 =1)

View 1 Replies

DataSource Controls :: Linq Distinct Ip According To Day?

May 4, 2010

I'm trying the pull out a result that shows me how many visitors I have had each day.

My database looks like this.

[code]....

View 5 Replies

ADO.NET :: How To Select The Distinct

Feb 9, 2011

Having some troubles selecting distinct rows.

[Code]....

This is not giving me the wanted results.

Two models:

[code]....

Each ContentVersion is linked to Content through the ContentID.

I want to select all "Content" where UserID = X, then for each selected "Content" I want the latest "ContentVersion".

The return type should be of type <IQueryable>ContentVersion.

View 21 Replies

DataSource Controls :: Using Varibale In The Where Clause?

Apr 21, 2010

I am having difficulties using a variable in the "where" clause:

declare @shift_started as datetime
set @shift_started = (SELECT *
FROM OPENQUERY(ADS_RGWP_SERVER, 'SELECT MAX(shift_started) as shift
FROM salestkt AS STK
WHERE NOT EXISTS(SELECT *
FROM SHFTDATE AS SD
WHERE SD.shift_started = STK.shift_started)'))
SELECT *
FROM OPENQUERY(ADS_RGWP_SERVER, ' sum(case when customer_type = ''Inter-Company'' then qty_shipped_today else 0 end) as intercompany_qty,
sum(case when customer_type = ''Charge'' then qty_shipped_today else 0 end) as outside_qty
FROM salestkt
WHERE shift_started ='" & @shift_started & "' ''')

Getting error:

Incorrect syntax near ' & @shift_started & '.

View 9 Replies

DataSource Controls :: Add Parameter To IN Clause In SQL?

Jan 28, 2010

i am developing an application using asp.net and backend server is SQL SERVER 2005.

in my application i have 12 regions. from that 12 regions user will select any of them.

if user select 1,2,3 then i have to pass this string to IN clause

for that i have storedproc like

create procedure sp_updateDistributorContractforAllRegions (
@unitprice float,
@region varchar(50)
)
update employee set UnitPrice=@unitprice where regionid in (@region)
end
GO

here regionid datatype in employee table is INT.

from code behind i am adding the parameter as 1,2,3.when i run the query it gives the error as

Conversion failed when converting the varchar value '1,2,3' to data type int.

View 3 Replies

ADO.NET :: Select Only One Distinct Record?

Nov 24, 2010

1.Category:
CatID(Pkey),
CatName,

ParentCatId(Fkey)=> CatID is used as a ParentCatId

2.Comp_Cat:
CCID(Pkey),
CatID,(fkey),
CompID

In my stored Procedure I am passing PageNo,CompID.. My requirement is that One parent CatName is displayed Per page but only one time.

View 4 Replies

ADO.NET :: How To Select Distinct With Count

Nov 3, 2010

This is something I can easily do in SQL, but I'm pretty new to LINQ and haven't been able to find an answer online.

I need a LINQ query that returns two values; the first a distinct value and the second the count of the first value. This is filtered by a parameter. Here is my table:

[code]....

View 2 Replies

DataSource Controls :: Insert Statement And Where Clause?

Apr 7, 2010

I am trying to do an insert statement to a table from classic ASP.I tried the below:

[Code]....

But, I am getting the error as: Incorrect syntax near the keyword 'where'.How to insert data, using a where clause in the above scenario?

View 5 Replies

DataSource Controls :: SqlDataSource - Parameter For IN() Clause

Apr 30, 2010

I have an SqlDataSource query that should use an input parameter for multiple integer values, like:

select * from table1 where TableID IN (1,2,3,4,5)

->

select * from table1 where TableID IN (@IDValues)

How do I do that ? Default parameter settings won't work, returning "invalid integer value" . I suppose that parameter should be passed as some kind of array that SQL recognizes as multiple integer values , but what's the correct way of setting this ?

View 4 Replies

ADO.NET :: Using Where Clause Before Select In LINQ?

Aug 26, 2010

why use where condition before select statement in LINQ

View 2 Replies

SQL Server :: Use Distinct With * In Sql Select Statement?

Mar 21, 2011

how can i use Distinct in my sql statement &#65279;like that

SELECT
Distinct * from my_table ?? ? ? ?? ? ? ?

View 2 Replies

DataSource Controls :: How To Pass Session UserName In Where Clause In Sql

Feb 28, 2010

SELECT DISTINCT TblSections.SectionID, TblSections.Description
FROM TblSections INNER JOIN
UMG.Users ON TblSections.SectionID = UMG.Users.SectionID
WHERE (TblSections.Description IS NOT NULL) AND (dbo.Users.LoginName = [@Session(UserName)])
ORDER BY TblSections.Description

I have problem in using Session name in the above BOLD WHERE clause.

View 5 Replies

DataSource Controls :: EntityDataSource Filtering / ESQL Where Clause?

Feb 28, 2010

I have a GridView that's currently bound to an ObjectDataSource. I would like to see if it's possible to instead bind it to an EntityDataSource. However, I need to be able to apply custom filters to it.

One of the filters corresponds to a bit / boolean property in the database / EntityDataModel. It has 3 possible selections:

[Code]....

[code]....

How can I accomplish the same thing in an eSQL Where clause? There is no COALESCE function, is there an equivalent?

View 1 Replies

DataSource Controls :: How To Update Dynamically A SQLdatasource With A WHERE Clause

Mar 10, 2011

I've already spent hours in searching through the forum to be able to do the following:I have a SQL datasource defined with a checkbox in it. Purpose is to update one column (userid) behind the table for only that row when the checkbox is selected.This is the code I'm currently having:

[Code]....

View 4 Replies

DataSource Controls :: Linq - Update Statement Where Clause?

May 25, 2010

I am using Linq to SQL. Tables have timestamp columns and I am using regular Linq methodology in ASP.NET MVC.I do use detached entities and always try to do updates without first querying the database for the original entity. To update an entity I use context.Attach(entity, true) followed by context.SubmitChanges() and all is fine. The sql statement that gets executed looks like:

[Code]...

View 7 Replies

DataSource Controls :: Use Stored Procedures From LINQ With A Using Clause ?

May 25, 2010

Ive created a new LINQ To SQL class and dragged several tables across from my server, in my code I access them like this

[Code]....this is all ok, however, I have several stored procedures that I want to use as well, but when I drag the stored procedures across I get a compilatiopn error

Error 60 'DB_BL.DB_BLDataContext': type used in a using statement must be implicitly convertible to 'System.IDisposable'

how do I use stored procedures from LINQ with a using clause ?

View 7 Replies

DataSource Controls :: Modifying WHERE Clause And Change To RegEx?

May 7, 2010

[Code]....

modifying WHERE Clause and change to RegEx?

View 1 Replies

SQL Server :: Select Statement With Where Clause?

Feb 14, 2011

I have a select statement:

cmd = new SqlCommand("select lab_key from tblorderwhere", connection);

I would like to add a where statement that pass variable to the select statement. How I can do this?

Where lab_key =ChargeFine( that is my variable)

View 2 Replies

DataSource Controls :: Returning All Rows Based On One Distinct Column?

May 18, 2010

Here is the query I have now which returns over 2 million records:

[Code]....

This works, but the result is littered with many rows that contain the same SSN. So how do I return only one row for each ssn? I cant use distinct because all of the other columns are already always different, this would return the same as above.

View 11 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved