Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > MS ACCESS query

Reply
Thread Tools

MS ACCESS query

 
 
Dave Harrington
Guest
Posts: n/a
 
      12-05-2005
Hi all -

I got a pretty basic question that's been bugging me today. I'm using
ASP.NET, C# and MS Access for a database driven application. I have a
datagrid that will populate based on a registered user's access level.
There are some instances where I'd like to use a basic OR statement in my
Access query, but I do not know the syntax. The statement I'd like to use
is below

cmd = new OleDbCommand("Select * FROM
"+Session["ClassroomSession"].ToString()+"WHERE AccessLevel=\"All\" OR
AccessLevel=\"Speaker\" ORDER BY ID", conn);

In this case, I'd like to populate the datagrid with all elements WHERE the
field "AccessLevel" is EITHER "All" OR "Speaker".

Please help!

Thanks in advance.

Dave Harrington


 
Reply With Quote
 
 
 
 
=?Utf-8?B?U3JpZGhhcg==?=
Guest
Posts: n/a
 
      12-05-2005
You need to enclose the strings in single quotes like this

cmd = new OleDbCommand("Select * FROM
"+Session["ClassroomSession"].ToString()+"WHERE AccessLevel= 'ALL' OR
AccessLevel='Speaker' ORDER BY ID", conn);


"Dave Harrington" wrote:

> Hi all -
>
> I got a pretty basic question that's been bugging me today. I'm using
> ASP.NET, C# and MS Access for a database driven application. I have a
> datagrid that will populate based on a registered user's access level.
> There are some instances where I'd like to use a basic OR statement in my
> Access query, but I do not know the syntax. The statement I'd like to use
> is below
>
> cmd = new OleDbCommand("Select * FROM
> "+Session["ClassroomSession"].ToString()+"WHERE AccessLevel=\"All\" OR
> AccessLevel=\"Speaker\" ORDER BY ID", conn);
>
> In this case, I'd like to populate the datagrid with all elements WHERE the
> field "AccessLevel" is EITHER "All" OR "Speaker".
>
> Please help!
>
> Thanks in advance.
>
> Dave Harrington
>
>
>

 
Reply With Quote
 
 
 
 
Paul Clement
Guest
Posts: n/a
 
      12-06-2005
On Mon, 5 Dec 2005 14:55:41 -0500, "Dave Harrington" <(E-Mail Removed)> wrote:

Hi all -

I got a pretty basic question that's been bugging me today. I'm using
ASP.NET, C# and MS Access for a database driven application. I have a
datagrid that will populate based on a registered user's access level.
There are some instances where I'd like to use a basic OR statement in my
Access query, but I do not know the syntax. The statement I'd like to use
is below

cmd = new OleDbCommand("Select * FROM
"+Session["ClassroomSession"].ToString()+"WHERE AccessLevel=\"All\" OR
AccessLevel=\"Speaker\" ORDER BY ID", conn);

In this case, I'd like to populate the datagrid with all elements WHERE the
field "AccessLevel" is EITHER "All" OR "Speaker".


You can also use the IN keyword:

SELECT *
FROM Table1
WHERE AccessLevel IN ('All','Speaker') ...


Paul
~~~~
Microsoft MVP (Visual Basic)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.NET won't retrieve query results that depend on union query Eric Nelson ASP .Net 5 02-04-2009 10:51 PM
Trying to query the Address table data of AdventureWorks database from Query Analyzer - need help! Learner ASP .Net 1 01-30-2006 08:58 PM
Build dynamic sql query for JSTL <sql:query> Anonymous Java 0 10-13-2005 10:01 PM
xpath query query David Gordon XML 2 05-18-2005 03:33 PM
CAML Query: Multiple Query Fields Issue Jon F. ASP .Net Web Services 0 05-12-2004 08:19 PM



Advertisments