ADO.NET :: Return String In LINQ Method?
Mar 9, 2011
I'm really new to ASP.Net and for a school project we have to create a login form. Now I have managed to create a login with LINQ doing the following:
[Code]....
And in my html page:
protected void Test_Click(object sender, EventArgs e)
{
if (Class1.Controle(Convert.ToInt32(txt1.Text), txt2.Text))
[Code]....
I was thinking something amongst those lines, but I can't call p.GebruikerWachtwoord. So I'm guessing this is completely wrong.I hope somebody can help me figure this out, and I apologise for the poor explanation, English isn't my native language.
View 3 Replies
Similar Messages:
Jan 15, 2011
i call FormsAuthentication.RedirectToLoginPage() to redirect to login page. but there is one problem: this method adds a return url to query string.how should i disable this?
View 3 Replies
May 27, 2010
If I'm returning an object, then it's pretty straight-forward. However, if I'm just trying to return whether or not the method was successful or not, what's the best option? Sure ... bool seems obvious - but what if you need to debug or get some additional details out of the method than just "yes/no"? Well that's where a string becomes more obvious, right? You can leave it empty to say that the method was successful or chock it full of details in the case of an error. But this can make it less intuitive to others who may have to run your functions and it also jumbles up everything you wanted to pass back into one large string.
View 3 Replies
Dec 14, 2010
I am using Entity Framework to contact my data base. as part of my web code I am using Linq to entities, and I want to determine the number of elements in an anonymous type list. I can't get it to work, I get the exception: "LINQ to Entities does not recognize the method 'Int32 Parse(System.String)' method, and this method cannot be translated into a store expression."
var questItem = from chapters in context.TestChapter
from questions in context.Question
where chapters.ID == int.Parse(Request.QueryString["id"])
where questions.TestChapterID == chapters.ID
select questions.ID;
int numOfSteps = questItem.Count();
how can I get it to work?
View 2 Replies
Sep 28, 2010
how can i return 401 error from a method return ActionResult?
View 1 Replies
Apr 13, 2010
I am creating an Asp.net web site which will support dynamic data. When I am creating a dynamic web site from Scratch (from template in VS) all is working fine. But when I am trying to add dynamic entity (.edmx) file and running the application I am getting following error
"The method 'Skip' is only supported for sorted input in LINQ to Entities. The method 'OrderBy' must be called before the method 'Skip'. "
View 2 Replies
Oct 6, 2010
I am struggling to create a webservice method using LINQ technology and to populate a dropdown in a form. Here is the Webservice code.
[WebMethod]
public
string[] GetAllCountries()
{
LinqClassesDataContext db =
new
LinqClassesDataContext();
var q =
from c
in db.ListContinents()select
c;
return q.ToList() ;
}
And here is the form code behind
protectedvoid
Page_Load(object sender,
EventArgs e)
{
WSClass WS =
new
WSClass();//bool
ds = WS.GetAllCountries();
var v = WS.GetAllCountries();
ddlContinent.DataSource = v;
ddlContinent.DataBind();
}
View 5 Replies
Aug 20, 2010
I'm using LINQ to query my database, and I don't want all the records returned all at once. Instead, user should be able to select Next 5 and Previous 5 using buttons. As of this moment I have selected the first 5 rows in the Item table in the databas like this:
private void ShowItems()
{
var items = (from p in db.Items
orderby p.ID descending
select new { ID = p.ID, Item = p.itemName,
Qty = p.quantity }).Take(5);
[code]...
View 3 Replies
Jun 18, 2010
I have a low level quiz. this is a mvc project
in PostRepository.cs, it has some code :
[Code]....
and then , in PostController.cs , I wanna a field in database call postStatus, the code is:
[Code]....
When I edit the post ,I hold the selectlist can show the option what is in database. But the code not work will.
then I use the Response.Write(postStatus); to test what happen. And the Browser show some code on top side :
[Code]....
I wanna what's up with the code and I want to know the suitable method.
View 2 Replies
Nov 16, 2010
i use JSon to return allot of results when building a website, but find myself writing a a lot of code like this:
[Code]....
and then simply call this function with whatever IEnumerable results i have my question is would i be on the right lines here, what would be the best possible way to do this as it makes no sense to be writing in MVC and OOP but to keep rewriting code to just FROM ?
View 5 Replies
Jun 30, 2010
Do any one know how to return an anonymous type. I am using Linq where i need to return the following code
private <What's the return type to be provided here> SampleLinq(Int32 Num)
{
var query = (from dept in obj.DeptTable where dept.Id == Num select new { dept.DeptName, dept.DeptId });
return (query)
}
View 8 Replies
Nov 24, 2010
I have a class file called ShoppingCartClass.cs. Inside ShoppingCartClass I have a method called CanadaPostShipping.
CanadaPostShipping get passed a lot of variables and then builds an xml, sends it to CanadaPost url and gets back an xml file with the shipping rates.
I would like to pass the xml back to my webpage so in my web page I can check that it has status ok and then extract the information I need.
My testing calling routine looks like this:
[Code]....
The start of my CanadaPostShipping routine looks like this
[Code]....
This is my current ending spot in CanadaPostShipping....where I am getting back the correct xml from CanadaPost
[Code]....
As you can see I am saving it to my thumbdrive.....
What changes would I have to make to my calling routine and the method in the class to return xml "mydoc"?
View 1 Replies
Sep 20, 2010
I am using .net framework 3.5 and sql server 2008.
In my project coding, I want to call stored procedures in sql server 2008.
return value is the object list which references the entity.
But I have the questions.
If in the entity named as "order", is it matching the properties or created through entity constructor??
In my case, I have two properties and one constructor which match one property.
public class orders
{
orders ( string orderid)
{
this.orderid=orderid;
}
public string orderid {get;set;}
public string orderno{get;set;}
}
View 1 Replies
Jan 18, 2011
[Code]....
[Code]....
creating Linq query in return statement
View 2 Replies
Jan 21, 2010
I have an autoincrement ID on some table.I need to know what is the ID of the new row when I add the object using InsertOnSubmit, but this method returns void.What is the common way of doing this.
View 1 Replies
Mar 25, 2011
I am consuming an RSS feed to display on my website using a repeater control. I was wondering if it's possible in VB to return an anonymous type from my linq query rather than a collection of strongly typed RSSItems. I know this is possible in C#, however haven't been able to work out a VB equivalent.
[Code]....
View 1 Replies
Mar 12, 2010
Is there a way opf getting the first value from a linq query so for example
[Code]....
View 2 Replies
Mar 16, 2011
I have this code in my controller:
public ActionResult Details(int id)
{
using (var db = new MatchGamingEntities())
[code]...
View 3 Replies
Apr 4, 2011
I am fairly new to MVC and just trying to achieve something which I think shouldn't be too complicated to achieve. Just want to know what the best approach for that is. I have an Event-RSVP application (NerdDinner kind) where you go to view details of the event and then click on an AJAX link that will RSVP you for the event.
<%
if (Model.HasRSVP(Context.User.Identity.Name))
{
%>
<p>
You are registered for this event!
<%:
Ajax.ActionLink("Click here if you can't make it!", "CancelRegistration", "RSVP", new { id = Model.RSVPs.FirstOrDefault(r => r.AttendeeName.ToLower() == User.Identity.Name.ToLower()).RSVPID }, new AjaxOptions { UpdateTargetId = "QuickRegister"})
%>
</p>
<%
}
else
{
%>
<p>................
View 2 Replies
Jul 19, 2010
I am coding a classic .asmx web service. The method get data (as a string) from a server, then assign data to an object, then return that object. But I want to cache that object to a XML file for other request. It's because the data from server is not frequently change. Thus, after some minutes, I have to refresh the XML file. When I refresh XML file, I could write object to XML first, then return that object, but that approach maybe slowly.
How can I return the object for client first, then write this to XML file?
View 5 Replies
Jul 9, 2010
VWD 2008 Express. Visual Basic.
I am using the Directory.GetFiles method as follows:
[Code]....
As expected, it returns files with the ".pdf" extension. I would like to be able to specify more than one extension (like "*.doc*" and "*.txt*", etc.). How can I use GetFiles to return files with more than one desired extension, without returning all files?
View 2 Replies
Oct 13, 2010
I have two methods that do the similar thing. There are small differences here and there, which I can control by passing arguments to them when I call them, so I can effectively merge them. However one returns a string, and the other one an ArrayList. On the top of my head, I could merge them and return an Object, and then get the information I need. Is there a way though to return multiple types in the method's signature? What's the proper way to implement this?
View 5 Replies
Jan 16, 2011
I am wondering if jsonResult method can be used to return Data Table? If so, is it a json array or a json string?
View 6 Replies
Mar 5, 2011
I have two tables: Projects and ProjectsData and I want to execute query with join and get the result in the View. In the Controller I have this code:
ViewBag.projectsData = (from pd in db.ProjectsData
join p in db.Projects on pd.ProjectId equals p.ID
where pd.UserName == this.HttpContext.User.Identity.Name
orderby p.Name, p.ProjectNo
select new { ProjectData = pd, Project = p });
What I should use in the View to extract this data. I tried that:
@foreach (var item in ViewBag.projectsData)
{
@item.pd.UserName
}
but it doesn't work.
View 1 Replies
Dec 15, 2010
I've recently inherited an ASP.NET 2.0 project from other developers and they have a LinqToSql datacontext with stored procedures. I've been asked to modify one of the SPs which is essentially just adding a couple columns to the database table and then those to parameters to the SP. So I delete the existing SP from the L2S context and drag in the new one with the additional fields, and all hell breaks loose. Suddenly I get over 20 errors! What seems to have occured is L2S has modified many other stored procedures that I haven't even touched and changed the return type from ISingleDefault<some object> to int. I've never used stored procedures before with L2S so I don't know if this is standard behavior or not. Does anyone know why this has happened and how to fix it to set the correct return type?
View 3 Replies