MVC :: Select Data And Display It From Two Tables?
Mar 28, 2011
I really have no idea what i am doing here, but all I want to do is display a one to many list from two tables in the database in a view.
I have a ChartController with the following code:
public ActionResult ChartCategoryOne()
var chart = from e
Now I need a view. The view that VS2010 creates via the PTP_AthleteExerciseResult model looks like just what I need. But I get the following error:
The model item passed into the dictionary is of type 'System.Data.Entity.Infrastructure.DbQuery`1[PersonalTrainerPro.Models.PTP_Exercise]',
but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[PersonalTrainerPro.Models.PTP_AthleteExerciseResult]'.
I'm not sure why it is passing PersonalTrainerPro.Models.PTP_Exercise, which is one of my automatically generated models derived from the database in the edmx and I have no idea how to set it up to pass IEnumerable instead of DbQuery. I actually have no idea what it means or even if I'm heading in the right direction.
Is there a way to select data from multiple tables other than the UNION ALL statement. Addtionally I need to select data from a different database.
My current statement is as follows (there are alot more fields but I have shortened it ):
SELECT server.dbo.SRFILE.SR_GROUP, server.dbo.SRFILE.SROWNERSHIP, server.dbo.SRFILE.SRCONMAE, BSFLBWF_1.Incidentx, BSFLBWF_1.Severityx FROM server.dbo.SRFILE INNER JOIN BSFLBWF AS BSFLBWF_1 ON BSFLBWF_1.Incidentx = server.dbo.SRFILE.SRONUMBER WHERE (BSFLBWF_1.Closex IS NULL).........
I have prepared a web project using ASP.net MVC. I want to display data by joining 2 or more tables and on Edit performing updation in 2 or more tables.
I have 2 tables : Employee_master(EmpID,Name,Designation) Employee_Detail(EmpId,Address,Phone,DOB).
I am using ADO.Entity framework to create the model.I want to perform following operations.
1.Applying 1:1 association between the tables. 2.To show the information EmpID,Name,Designation,Address,Phone for all the existing records in tables on View. 3.On Selecting the Edit link want to show EmpID,Name,Designation,Address,Phone for the corresponding EmpId in EditView and then perform updation of the records in 2 tables both in Employee_master,Employee_Detail on Save.
how can I display on a single page(View) data from two tables in my db? In my project the model is *.edmx file. i have two table one with categories, and the second one with products. All I want to do is to display on home page(view) in left column all categories, and all products in right column. After clicking on category in left column, in right column there should be products form category which was clicked....
I am having a hard time solving the following with an MVC view. My goal is to display data from multiple tables in a single MVC view. The bulk of the data comes from a table called Retailers. I also have another table called RetailerCategories which stores the retailerid from the Retailers table and also a categoryid linking to a Category table. Note that there are multiple records for each retailerid in the RetailerCategories table.
In the view I want to show a list of retailers and with each retailer I want to show the list of categories applicable to them. What would be the best way to accomplish this?
I have two tables. 1st contain topic and its id. 2nd contain topic name,its category and category list.
I want to display using asp .net datalist and vb script like the following
topic 1 Category 1 categorylist 1 of category 1 categorylist 2 of category 1 Category 2 categorylist 1 of category 2 categorylist 2 of category 2 topic 2 Category 1 categorylist 1 of category 1 categorylist 2 of category 1 Category 2 categorylist 1 of category 2 categorylist 2 of category 2
Also, i have tried displaying only Category 1, 2 .. which are Link button. When I click these button it shows category list. So here I am facing aproblem that everytime i click these buttons it refreshes my page which is very annoying.
i have a problem in joining two tables the reason ismy first table persdata is having common field as pno (a single row in a particular person) and the second tables is also having pno(having muti entry for a person as this table is of qualification and a person may have more than 3 qualifications and their grading)sample persdata(table)pno name coy appt sample qual(table)pno qual grading recommendationi tried my best to do it and not able to proceedi want the output in a single row as in persdata to a gridview with all the qual combined in one coloumn and all the recommendations combined in one coloumn for a person.
In my application, I need to get data from three tables and display them in 1 view. I have created a .dbml and created a ViewModel in my Models folder to deal with this. Here is my ViewModel:
My web application uses the Default ASP.NET Membership. So User [ u ] is of type aspnet_Users from the default Membership. This ViewModel allows all the CRUD opertation to be carried out. However on the Create and Update operations, I would LOVE some Model Validations, My question is:
1) Would the User [ u ] default validation kick into place in my ViewModel ? Cause I know by default ASP.NET Membership, has Model Validation.
2) For table SUserDetails (which I have created myself, not part of default) how do I add ViewModel validation to it for when someone does an Update or Create?
I have 3 tables in single database with different strctures,3 tables have unique column(partno or Jobno) , on web form search button input control(textbox) and grid view.I am pulling the data based on column jobno from single table on to grid view using following code
SELECT u.Email FROM UserProfiles p, aspnet_Membership u WHERE p.RulesCheckBox = 'True' AND u.UserId = p.UserId This gives me a list of registered member email addresses that have selected the RulesCheckBox in their profile, so I can email them with an email script. There is a relationship between the Membership table and the UserProfile table, so it finds the email addresses from the Membership table where that user has the RulesCheckBox checked in their profile (in UserProfiles table). I'm wanting to add some additional names to this list, from a different table. The purpose is so I can manually add email addresses to the additional table, so the additional email addresses will also receive the same email, even though they aren't registered members of the site. So how can I adjust that SELECT statement so this one is combined with it somehow?:
SELECT Email FROM ExtraEmails WHERE Rules = 'true'
I want to select the number of goals, assist and cards a player has in a specific tournament. I tried with this query but then the goal and card column shows the sum of the number of rows matching the playerid in the Goal table and the Card table...For example if there is two matching rows in the goal table and three matching rows in the card table, I get 5 in both these columns in the resultset.
sql_select = "SELECT auid FROM tbl_auAccount WHERE username='" & IUN & "'" 'Add Error Trapping Later con = Server.CreateObject("ADODB.Connection") con.Open(data_source) 'Execute the SQL Command con.Execute(sql_select) 'Close the connection con.Close() con = Nothing
Now this works and I was able to put the value into a dropdown list box, but I need the value returned placed into a label such as:
lblShowNewUserID.Text = ? (? being the value returned from the Query). I thought this would be simple, but it is not (at least for a newbie like me). NOTE: (I will have instructions before this to be sure that only one value will be returned and taht the value will not be null).