Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   MS ACCESS query (http://www.velocityreviews.com/forums/t114895-ms-access-query.html)

Dave Harrington 12-05-2005 07:55 PM

MS ACCESS query
 
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



=?Utf-8?B?U3JpZGhhcg==?= 12-05-2005 10:25 PM

RE: MS ACCESS query
 
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
>
>
>


Paul Clement 12-06-2005 07:39 PM

Re: MS ACCESS query
 
On Mon, 5 Dec 2005 14:55:41 -0500, "Dave Harrington" <dharrington@shaws-lawson.com> 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)


All times are GMT. The time now is 02:33 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.