Hi,
Am very new to silverlight, and am working on this module where
i want to retrieve some data from database, the problem is when i
mention column names it dosnt work properly and it gives an error at
the return statement....the code is below...
Public Function GetLoginName(ByVal strLogin As String) As List(Of tbl_User) Implements IService1.GetLoginName
Dim db As New DataClasses1DataContext
Dim matchingLogin = From Login In db.tbl_Users Where Login.UserName.StartsWith(strLogin) _
Select Login.UserName, Login.Password
Return matchingLogin
End Function
Can any1 tell me how to achieve it ..
Thanks in advance
Loading
Pedro BarbasPosted Aug 20, 2009, 4:35 AM
Return (IList
sunilPosted Aug 20, 2009, 12:52 AM
Pedro BarbasPosted Aug 19, 2009, 8:15 AM
Then when this returns, work with the array and you can loop without a cast error.
And please don't forget to Check "Do You Like This answer" if this has helped you. Thanks!
sunilPosted Aug 19, 2009, 7:20 AM
I am getting the following error, in
Return matchingLogin
Unable to cast object of type 'System.Data.Linq.DataQuery`1[VB$AnonymousType_0`2[System.String,System.String]]' to type 'System.Collections.Generic.List`1[E_Learning.Web.User]'.
I have tried to use
Return matchingLogin .To List
but it will only work if i dont mention any column names i.e
Public Function GetLoginName(ByVal strLogin As String) As List(Of User) Implements IService1.GetLoginName
Dim db As New DataClasses1DataContext
Dim matchingLogin = From Login In db.Users Where Login.UserName = strLogin _
Select Login
Return matchingLogin.ToList
End Function
Meetu ChoudharyPosted Aug 19, 2009, 6:57 AM