I have an C# ASP application I am writing that needs to have the capability to import a generated excel or a comma delineated sheet each day. A clerk will have this job each morning so it doesn't need to be automated. My problem in trying to understand the solution to this is that the 1 sheet contains loan information, including customer information all in the same sheet. I would like to send certain columns to update information in the loan table and send other information to update the customer table. I need it to create relationships when new loans appear in the spreadsheet.
I am new to MVC and am trying to join 2 SQL tables together and return them in a Json. One table is OutreachProgram. The other table is UserInfo. I want to return the rows from the OutreachProgram table that match on CenterID with the UserInfo table.
The code that exists now will pull all rows from the OutreachProgram table. I can't figure out how to add the UserInfo table to the query to make it work.
JsonGrid <OutreachProgram> grid = new JsonGrid<OutreachProgram>(db.OutreachProgram, new OutreachProgramFilter()); public Array GetItems(IQueryable<OutreachProgram> source) { return (from r in source.AsEnumerable() select new { ID = r.OutreachProgramID, CenterID = r.CenterID, DateOutreachProvided = r.DateOutreachProvided.ToShortDateString(), NameOfProvider = r.NameofProvider.ToString(), }).ToArray(); }
I was in need of exporting multiple tables in a DataSet to an Excel file with multiple sheets. I found a very good article in [URL].[URL] was able to successfully export each of my datatables in the dataset to excel worksheets. This solution worked for small number of rows. But when the data got larger I am consistently getting the system.outofmemoryexception. THis is because the code is using up the memory when creating excel.
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 }
I am having a problem returning a value from a stored procedure when using SqlDataSource. The stored procedure is executing because 'invoice_no is incrementing but Myreader.HasRows is always false.
CREATE PROCEDURE `GetInvoiceNumber`(IN username VARCHAR(50), OUT InvoiceNum INT) BEGIN INSERT INTO invoice (employee) VALUES (username); SELECT MAX(invoice_no) INTO InvoiceNum FROM invoice; END
I want to get data from Projects(which have CourseId) and related CourseName from Courses table.
I have written following code:
var projects = from n in db.Projects join c in db.Courses on n.CourseId equals c.ID orderby n.Name select new { Project = n, Course = c }; return View(projects.ToList());
and I get error:
The model item passed into the dictionary is of type 'System.Collections.Generic.List1[<>f__AnonymousType22[ProjectManager.Models.Project,ProjectManager.Models.Course]]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[ProjectManager.Models.Project]'.
What I need to do in Controller and in View to display this data?
is there any way that i could export multiple tables already formatted into multiple excel sheets. I know how to export data to multiple sheets through dataset while looping through tables, rows and columns and then add styles.
But I really want to export formatted html tables each into seperate sheet
I have 5 tables of which one has a primary key called "pid" as follows in patientdetails table the pid of a patient is used to compare the pid in remaining tables so the data in matching pid records can be stored in dataset. I tried using stored procedure to get them together in one dataset but it just doesent happen. This is my stored procedure,
[Code]....
I think the execution doesent proceed after the first if exists statements, because only the data in patientdetails is stored in dataset. and one more thing. all test tables need not contain a data against every pid in patientdetails table.
I want to get the total data of my table and store into one variableThis is my code...but it gives me error like 'Invalid attempt to read when no data is present.'
I have 10 tables in MSSQL I want to select some info from this tables and show on a webpage (formview maybe(based on user selection)). Also, Id like user to be able to EDIT this info, and it should go back to database.
The problem is that: the realtionships are pretty comprehensive. In sql management studio I saw awesome view creation, where u can drag and drop tables and select just the field u need, and it automatically do all joins for you.
View would work perfect for me, but i need to update database back. Maybe I can use linq classes?
I mean, its easy, but it takes a lot of time to do it by hand programatically. Is there some dragandgrop-like feature in visual studio?
what is the easiest way to bind multiple tables in one place with crud operations available?
sql datasource supports only 1 table at a time.
I Found on the web that we can use stored procedure? Do I need two stored procedures? for select and update? how we are going to bind update procedure with textobxes where user is going to edit info? Do you have some samples?
I have a partitioned db where several tables have the exact same structure. I'm able to query the tables using linq, but only by quering the individual tables 1 at a time and by using the explicit table name. For example at the moment, I have 8 tables so I have something similar to the following:
[Code]....
Is there any way, that based on a certain value (stringValue), I could determine which table to query and then code the linq query just once?
I am having a strange problem with and RDLC report with two tables in it. The tables are not related, nut I need them both on the same report. In my project, I created a typed dataset with two datatables in it (no tableadapters). IN my rdlc, added two datasets, one for each of the datatables. I then built the two tables in the report to use the appropriate dataset. When the application runs, I manually add data to the typed datasets and then add them as reportdatasources, etc. Now, all of this works fine if I have only one dataset in the rdlc. But, when I have two, I get an exception when I call lc.render(...). Digging through the inner exceptions, I end up with "DataSet1" as the inner most exception message.
have a database and I've created a DBML Linq-to-SQL file to represent this database. I've created a new aspx page and dropped a linqdatasource and a formview control onto it. When I configure the linqdatasource it gives me the choice only to select * from one table...but I want to pull from multiple tables. e.g. I have tables like simple_person, simple_address, simple_phone, and I want to pull from all of them.
In my project, i have a DBML file which is acting as a Data Access Layer. There one more utility method that is converting the existing result into dataset. Below is my method:
I am accessing rows in an SQL database table based upon the contents of the Primary key and another column. But, I cannot insert new rows in the table when the content of the new Primary key column already exists in another row. Can I define the table with a multiple column Primary key so that a unique value can be based upon the content of both columns?
I have a couple tables that are kind of unrelated - id like to search through both of them and create a type that i can sift through later
something like this doesnt work
[Code]....
I basically want to create a list of "AnimalSearchResults" that contains all dogs and all cats that have that name Whats the best way to do something like this?