I have a .Net Entity Framework application. My data from DB is pulled correctly, but while displaying on the JQGRID, for some reason all of the 200 records are displayed correctly except for 1 single record (it has similar structure and data as other records )
Any ideas as to why this problem would come?
Edit : There are 2 similar records with fiscal year different, 1 has FY13, other is FY15. If I view the running website while debugging, both FY13 and FY15 records are displayed, but if I directly run the application (without debug mode ) only FY13 which is the first record order wise before FY15 is displayed and FY15 record is not displayed.
Can anyone explain this weird behavior ?
Related
This past week I was tasked with moving a PHP based database to a new SQL database. There are a handful of requirements, but one of those was using ASP.Net MVC to connect to the SQL database...and I have never used ASP.Net or MVC.
I have successfully moved the database to SQL and have the foundation of the ASP site set up (after spending many hours pouring through tutorials). The issue I am having now is that one of the pages is meant to display a handful of fields (User_Name, Work_Date, Work_Description, Work_Location, etc) but the only way of grabbing all of those fields is by combining two of the tables. Furthermore, I am required to allow the user to search the combined table for any matching rows between a user inputted date range.
I have tried having a basic table set up that displays the correct fields and have implemented a search bar...but that only allows me to search by a single date, not a range. I have also tried to use GridView with its Query Builder feature to grab the data fields I needed (which worked really well), but I can't figure out how to attach textboxes/buttons to the newly made GridView. Using a single table with GridView works perfectly and using textboxes/buttons is very intuitive. I just can't seem to make the same connection with a joined view.
So I suppose my question is this: what is the best way for me to combine these two tables while also still having the ability to perform searches on the displayed data? If I could build this database from scratch I would have just made a table with the relevant data attached to it, but because this is derived from a previously made database it has 12+ years of information that I need to dump into it.
Any help would be greatly appreciated. I am kind of dead in the water here. My inexperience with these systems is getting the better of me. I could post the code that I have, but I am mainly interested in my options and then I can do the research on my own.
Thanks!
It's difficult to offer definitive answers to your questions due to the need for guesswork.
But here are some hints.
You can say WHERE datestamp >= '2017-01-01' AND datestamp < '2018-01-01' to filter all the rows in calendar year 2017. Many variations on this sort of date range filter are available.
Your first table probably has some kind of ID number on each row. Let's call it first.first_id. Your second table probably has its own id, let's call it second.second_id. And, it probably has another id that identifies a row in your first table, let's call it second.first_id. That second.first_id is called a foreign key in the second table to the first table. There can be any number of rows in your second table corresponding to your first table via this foreign key.
If this is the case you can do something like this:
SELECT first.datestamp, first.val1, first.val2, second.val1, second.val2
FROM first
JOIN second ON first.first_id = second.first_id
WHERE first.datestamp >= '2018-06-01' AND first.datestamp < '2018-07-01'
AND (first.val1 = 'some search term' OR second.val1 = 'some search term')
ORDER BY first.datestamp
This makes a virtual table by joining together your two physical tables (FROM...JOIN...).
Then it filters the rows you want from that virtual table (FROM ...).
Then it puts them in the order you want (ORDER BY...).
Finally, it chooses the columns from the virtual table you want in your result set (SELECT ...).
SQL database servers (MySQL, SQL Server, postgreSQL, Oracle and the rest) are very smart about doing this sort of thing efficiently.
I ask for advice what would you suggest to display 2 unrelated tables in a single report (if needed with subreport), the first one with groupings and the second one "flat"?
Details:
I am developing a report with C# 4 and Crystal Reports for Visual studio.
Data comes from a Stored procedure in Sql Server 2005, that returns 2 tables.
I pass the data to the report with the .SetDataSource(Dataset) method and I checked that data in the dataset is correct.
I need to display the data from the first table in a quite complex form with different sections. This part works.
At the end of the report I need to print the data from the second table (no grouping, just a "flat" print). To do this I added a subreport.
The tables are not related. I added a Dummy field on them with the same value and used it to mimic a relation in the database expert; I configured the subreport link, based on the dummy field.
I have 2 problems.
The data in the main report is cross joined with the second table (I could expect that since they are related with a constant field)
The subreport is always empty (I checked several times that its table in datasource contains correct data).
I tried different configurations of link and tried to place the subreport in different sections (It should be in the report footer).
I set a border around the subreport: the border is printed but inside it is empty.
I also setup a formula to count the records of both tables and put the count in the report: the count is > 0 for both.
Your approach looks wrong.... At first if both are not releated I don't see any use in creating a dummy field and linking tables which will always provide cross join. Any way as per your descrition table 1 data is saperately displayed and table 2 data is saperately displayed
As per your description in main report you need data from table 1 and in footer you need data from table 2.
Try this approach:
Don't link tables
take table 1 in main report and show the required display.
Take sub report and in that take only table 2 and display in footer and make sure don't link main report and sub report nor link two tables.
Ideally speaking, without linked table not used in crystal report as reporting tools used to display the relevant data based on our criteria and display 2 different set of data without link does not mean as a report as well as tough to integrate in crystal report.
Tough to integrate means at any point you have to link the table either via union in sqlserver or at crystal report side, other wise it display as Cartesian.
As per my thoughts you can do it by some approach.
Approach 1 : You can get the data by union or unionAll with set of columns and filter the data where table's column does not have null value ie.
http://www.maximumimpactsolutions.co.uk/blog/comments.asp?bd=118
Table1col1 Table1col2 Table1col3 Table2Col1 Table2Col2 Table2Col3
value value value null null null --table1data
null null null value value value --table2data
Approach 2 : Second is sub-report, but still need the linked as you already done. But there is proper rule to be set (this is very very tedious job).
Approach 3 : Generate 2 report at c# side and merge into one PDF, then export it.
check this links.
Reporting on multiple tables independently in Crystal Reports 11
http://www.tek-tips.com/viewthread.cfm?qid=241195
http://www.crystalreportsbook.com/Forum/forum_posts.asp?TID=4756
http://www.codeproject.com/Questions/348959/Crystal-reports-for-multiple-tables
I am utilizing Devexpress Gridview and I am having a caching problem.
I have developed a page like here: http://mvc.devexpress.com/GridView/SimpleCustomBinding
It is working as it is supposed to be. However, if I update a column value in the database (Mssql), Gridview does not change the value.
Searched the web and found EnableRowsCache must be false but I could not implemented it since I think this property is available for different kind (or version) of Gridview and We have been using MVC extensions.
Does anybody know how to disable cache and make it show the "fresh" data?
------ UPDATE ------
After a lot of digging and searching, it is clear now that the caching is not due to devexpress, but it is the result of linq to sql. It is a property of linq that it caches the results of view and does not show the updated value.
This issue was a major headheache to us and now I have come up with a conclusion with my colleague.
PROBLEM
First of all, suppose that you have a view in your db, name: ViewBook
ViewBook
Id | Title | Author
And you write the following query:
(from VB in Connection.ViewBook
select VB).ToList();
As a result you will get a list of rows.
Then, if you update a row in your db, this query will not show the fresh data, still returns the old data.
SOLUTION
In order to solve this, first define an object:
public class ViewBookObject : ViewBook
{
//this object will have all the properties of ViewBook.
}
then in the query:
(from VB in Connection.ViewBook
select new ViewBookObject {
Id = VB.Id,
Title = VB.Title,
Author = VB.Author
}).ToList();
This query will always show the fresh data.
CONCLUSION
I have written this solution to here for people who have similar problem to this situation.
I hope this helps everyone.
I am working on a system which now requires versions to be maintained.
Will explain you the project in brief.
We have a CMS in which there are three users 1. Super Admin, 2. Editor, 3. Approver.
Editor add's data from CMS and send it to approver if he approves the data only in that case it is visible on the front end. Now if the editor edits the same data then its disapproved and removed from the frontend and agian he will send it to the approver and the same process will follow. This is how its working now.
The client has now changed the requirement and now what he wants is that once the data is approved and visible in the site i.e frontend and the editor now edits the data it should not be removed from the frontend and new edited data should be send for approval and when the approver approves the data the old one should be replaced with new one in the front end.
The database design is real bad so it's going to be difficult to achieve this.
The solution that we have thought of is...
For example the Editor can add some kind of news in the front end. All the data w.r.t news is added in news table. Editor add's the news sends it for approval and then he approves. Till here there are no issues. Now suppose that for some reason he wants to edit the same news which is approved. The moment he clicks on edits button it is removed from front end so what we thought is like maintain another table something like temp_news with the same structure and the moment he clicks on edit news after its being approved a new record should be inserted in temp_news table with the values from news table added in this table. Till then in frontend we will display the news from news table. So now we have the same news data in two tables. Approver and editor can now do all the changes and we will update the temp_news table. The moment approver approves this changed data we will update the new's table with values from temp_news table. so now in front end we have the updated new's.
The problem with this solution is that once the changed is approved both tables news and temp_news have the latest data. This not versioning.
Need a solution for this.
I am just a beginner.
I would just have one table that you use to store multiple versions of the same data
news
----
ID int
newsItem int
dateCreated datetime
IsApproved boolean
content text
Then for display on the front end. Just
SELECT top(1) * FROM news where IsApproved = true orderby dateCreated desc
So the front will only show the most recently approved version.
and newer version will just get a new ID and dateCreated but the isApproved would be false
so say if you had 3 version of the same news item. it would look like
ID newsitem dateCreated IsApproved
1 1 2011-4-26 false
2 1 2011-3-20 true
3 1 2011-1-6 true
How about a version control system like Git? Keep the versions, including the one to be approved in Git and the approved one in database table ( only one .) When a new one is approved, move it to the db. Since you are using C# and ASP.NET, something like git# might be helpful for you
People are already doing this:
This is a django website with a twist:
all content is stored in text files. I
manage those files with git. A little
script loads those files into the
database and then django serves them.
In fact, all of the content and its
history is actually publicly available
(but you don't have to make your
history available in order to use this
system). You can all see this an
example of how to use django-gitcms.
http://luispedro.org/software/git-cms
http://nestacms.com/docs/creating-content/publishing-articles-with-git
Git-based content management?
Hey everybody, got an interesting question I think. I've got a Silverlight3 application which is querying a SQL Server 2005 database asynchronously. However, some of the data sets the queries return are massive and so I'm looking into data pagination.
Goals:
1) Just in time data calls - I only want to query for page 3's data when the user clicks to go to page 3.
2) I want a slider to control which page I'm on - SliderControl is SL3 with its movement binded to a stored procedure call (is my initial guess as to an approach).
3) Read ahead data as a label for the slider. So the slider will say "Page 1 of 50" or perhaps "Gant - Hart". Some sort of indication as to where you are in the data without actually querying for all the data until the user drops the slider into position.
I'm almost positive that I need to do some sort of a query to get the total number of rows and some sort of bookmark data that the query will eventually return. Otherwise I don't know how to split up the slider nor would I be able to do page labels (The gant to hart stuff).
Anyone have experience with this kind of thing? Thanks.
There are usually at least 2 separate lookups involved here, the first to get the pager information and a second to retrieve the data appropriate to the current page.
The pager (slider) needs to know the total number results that would be returned if you weren't doing paging. This is needed to show the pretty "Total # of Results" indicator for your use and to calculate how many total pages you've got. In your case you're going to want to format a nice visual display of the pages for selection (determined by your desired records/page value) in your slider. That's your first query; it should return just a single scalar int or long and you can calculate what you need for your slider display.
The second results include the actual records to be displayed for a given page.
Step 1 of 2 for a page of data is to run a query to filter and order your results by a primary key present within the data you're returning, throwing the key values in a temp table with an AUTO_INCREMENT/IDENTITY field or getting the row number over for the results of a derived table. (Summary: 2 fields, 1 for sequence/1 for primary key to join in step 2).
Step 2 of 2 is to join the key values with your tables which contain data, ordering by the sequence determined in Step 1, selecting only rows numbered (desired start row) to (desired end row) as determined by the page number and page size you've selected.
A stored procedure is strongly advised to keep the data on the server during this operation while you're having to examine more data than you really care to bring back to optimize bandwidth.