LinqDataSource Using Enum In Where?
Dec 30, 2007
Not sure where the best place to ask this question is so I will ask it here. I am trying to use the LinqDataSource ASP.NET 3.5 control and am having a problem with using the Where attribute. I have a field that I want to filter on that is an Enumeration, however if I try to put the integer value in the Where attribute the page will not compile. How do I use enum values in the Where attribute?
I have something like this:
public enum EventType
{
Charger = 0,
Location = 1,
Scanner = 2
}
I want to filter the LinqDataSource like this:
<asp:LinqDataSource ID="DataSource1" runat="server"
ContextTypeName="MyDataContext"
Table="Events"
Where="EventType = 2" />
This won't work. The EventType property is an instance of the enum type above.
View 2 Replies
Feb 1, 2008
Dear allIn Visual Studio 2008,Shall I use the SqlDataSource or LinqDataSource when I try to retrieve data rows in SQL Server?I do not know how to write SqlConnection code to connect SQL Server, but also know how to use Linq to SQL class.Which one is better?Can LinqDataSource replace SqlDataSource?Thanks for your reply.
View 3 Replies
View Related
Nov 30, 2007
Hi everyone,
I'm trying to query a database table using LinqDataSource and get the rows 'WHERE ParentId IS NULL'. I set the AutoGenerateWhereClause to True, catch the Selecting event and set ParentId to null like so:protected void MyLinqDataSource_Selecting(object sender, LinqDataSourceSelectEventArgs e)
{
e.WhereParameters["ParentId"] = null;// this doesn't work - why?
}
but this is ignored. I've also tried e.WhereParameters["ParentId"] = DBNull.Value;
but this doesn't work either!
Is there a way of doing this?
Thanks!
View 11 Replies
View Related
Nov 7, 2007
Hi,
Using VS.NET 2008 Beta2, and SQL Server 2005.
I have a gridview bound to a linq data source, and when trying to update a row, I get an exception that no rows were modified.
The query generated is:
UPDATE [dbo].[package]
SET [owner_id] = @p5
WHERE ([package_id] = @p0) AND ([title] = @p1) AND ([directory] = @p2) AND ([owner_id] = @p3) AND ([creation_date] = @p4)
-- @p0: Input Int32 (Size = 0; Prec = 0; Scale = 0) [20006]
-- @p1: Input String (Size = 22; Prec = 0; Scale = 0) [Visual Studio.NET 2005]
-- @p2: Input String (Size = 26; Prec = 0; Scale = 0) [MSI_Visual_Studio.NET_2005]
-- @p3: Input Int32 (Size = 0; Prec = 0; Scale = 0) [10000]
-- @p4: Input DateTime (Size = 0; Prec = 0; Scale = 0) [11/07/2007 12:00:00 a.m.]
-- @p5: Input Int32 (Size = 0; Prec = 0; Scale = 0) [10001]
-- Context: SqlProvider(Sql2005) Model: AttributedMetaModel Build: 3.5.20706.1
If I run it manually on sql server, it fails until the directory column is removed. The type is varchar(50), with a uniqueness constraint. However, this is same type as the title column, which doesn't have this problem.
Thanks,
Jessica
View 5 Replies
View Related
Feb 6, 2007
hi, i'm new to sql. Any idea how to make enum type in micr. sql server management studio 2005. I need something like this:
field_name char enum ('I', 'J', 'K')
pleaase help me!
View 4 Replies
View Related
Sep 21, 2007
hi guys,
is it possible to do a enum datatype in SQL Server? if so can anyone point me to an example please?
thanks,
benny
View 3 Replies
View Related
Jan 21, 2008
I have an asp.net custom class which has a property using Enum types. For information, it is an "orders" class and the property is "status", with types:
OrderStatus.OpenOrderStatus.CompletedOrderStatus.CancelledOrderStatus.Refunded
each order is stored as a row in a SQL database table. How can I store the Enum type in the database?
I assume that I could have an integer column with values 0 - 4 and convert to and from the integer/enum type each time an order is read or written, but it would be much better if I could store the enum type somehow without having to convert.
Any ideas?
View 1 Replies
View Related
Feb 12, 2008
Hello,
I want to enumerate all the RUNNING SQL instances[in a mixed env where SQL 2000 and SQL2005 are deployed] using SQL DMO.
But any of the following methods would not help
ListAvailableSQLServers Method
ListInstalledInstances Method
because they list all the installed instances and while my intent is getting only the running instances.
Is there any other direct API ? Pls advise.
Regards,
Velu
View 1 Replies
View Related
Aug 28, 2006
Hi,
Can't seem to find a similar data type in MSSQL like the one very handy ENUM type existing in e.g MySQL:
... Enum('on','off','standby') ...
It's also a convinient way to check for true/false. I'd appreciate any suggestions on possible "workarounds" or sources that might point me in the right direction.
Best
View 1 Replies
View Related
Nov 25, 2006
hi
what is the diffrence between the cursor type of the recordset enumeration values in ADO
dynamic
openkeyset
static
forwardonly
thanks in advance.
View 3 Replies
View Related
Jan 17, 2007
I have a SQL database table with all languages used in my application.
I would like to use an enum or constant class with all the languages, so every developer of the app sees directly what languages are available.
Can this be done?
View 5 Replies
View Related