I am working for a Windows Application using WPF, c# in Visual Studio 2010 and Crystal Reports. I can create a report easily by adding a DataSet item to the project first, add tables to it and setting it as a datasource for the Report. What I need to do is create a dataset that can fetch data from tables that generate from time to time.
*For Ex- If the current year is 2012, the dataset should fetch information from table FEE_2012_2013, or if the current year is 2013, it should fetch the data from the Table FEE_2013_2014. I am creating these tables at runtime. How can I achieve this? Please help.*
Edit: I guess I need an alternative to STRONGLY TYPED DATASETS FOR CR.
Here is an article on how you can come close to what you want:
Its quite complicated and you will have to spend some time on it to alter it to your requirements.
Read this
One of the quicker and better ways will be to just keep one table and add an additional column for an academic year.
Just design the report with a generic table name, and then update the report schema at runtime to match the current database schema.
myReport.Database.Tables("FEE").Location = "MyDatabase.dbo.FEE_2013_2014"
Table.Location
Related
In SSRS I have changed some tablenames and want to change the queries in all the reports that use those tables.
I have no trouble changing the queries. But when I run the reports in reportmanager they still use the old code.
If I edit the report in reportbuilder I can see that the code is changed.
If I save the report in reportbuilder then the reportmanager uses the correct code.
How do I make the change through a query without having to open each report and saving it again?
You can create a SYNONYM for the old table name to reference the new table name and your reports will still run correctly.
CREATE SYNONYM OldTableName FOR NewTableName
For more information please see this excellent introduction
http://www.sqlservertutorial.net/sql-server-basics/sql-server-synonym/
I have an Excel file that looks like the below
System | Status
Test OK
Test2 Down
Test3 OK
I also have a SQL server table with the same columns.
What I want is a button on the Excel sheet that once clicked, will truncate the SQL table and insert the values from the Excel table into the SQL table.
I have tried the below step but I am struggling due to my lack of understanding of developing in Excel (I am a SQL developer)
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/84725bcb-328d-4aed-8b95-d2c34dc46be4/need-to-update-sql-server-table-on-click-of-excel-button?forum=sqldataaccess
Any help would be massively appreciated!
Thanks
We have created an Excel Add-In for updating tables from Excel to SQL Server which have a Save button that will save your changes in Excel to the mapped table in SQL Server. The Add-In is built for non-technical people so it is rather straightforward to set up the spreadsheet without having to write any code.
It won't truncate the table, but there are a couple of ways to update the table which hopefully will give you the same result. Without knowing your exact use case, I would propose to either just do an update of the table from Excel if that meets your requirements, or add a timestamp column and let the Add-In write the timestamp to each updated/inserted row and then only use the last updated/inserted rows (you can also let the Add-In delete all previous rows after a new insert).
If that's of interest, you can read more here and download a free trial.
Disclaimer: I'm the founder of the company.
I am building a simple database with about 6-7 tables. I will be setting a schedule to do a clean import from a .txt file.
I want to take this data and create a report, like I would do in an excel spreadsheet, convert it to a pdf and post it to our company intranet for those interested to access it.
I'm trying to think of the best way to build my report. Would I just use an excel spreadsheet with a direct connection to the database? Would I create some sort of console application (c/c#/vb/vb.net) that would query the db, generate the report in an excel file, convert to pdf and save?
I'm quite comfortable in these different languages, just not as experienced in the reporting services (although I do have a lot of experience working with EXCEL and VBA Macros) but I want to get into it (SSRS) and get familiar with it as I will be doing a lot of projects like this in the future. This is seems like an easy one to get my hands dirty with and learn and build off of.
Any insight or suggestions would be greatly appreciated.
Thanks so much!
My suggestion:
Create desired SQL queries to retrieve the data in desired form
Link these queries to your Excel sheet, perhaps directly in form of pivot tables for aggregation of results
Using VBA, you can easily create PDF from the data at the click of a button
The initial design will be time intensive, but after that, everything is automated and one just needs to press the button that creates the PDF.
How to link Access queries to your Excel file:
Data --> Get external Data
You can easily refresh all data whenever you open the Excelsheet by using the code below in the On Open event of the workbook:
ThisWorkbook.RefreshAll
If you need further clarification, do not hesitate to ask
If your end goal is to create a PDF that will be out on your intranet then I would create the report in SSRS. Then you can schedule it to run and output a PDF to your network location.
I've had good experiences using a pivot table in Excel which is a connected table to your SQL database.
In the connection parameters in Excel there is a field where you can define your SQL query, whether it be to call a stored procedure or just a simple SELECT statement.
The main reason I prefer a pivot table SQL connection rather than a normal table connection is because if you have a chart that references the connected table, the chart formatting will be reset when you refresh your connection (if you need to updated your report).
If I use a chart that references a pivot table (or a pivot chart) then the formatting is retained.
sol have a standard self referencing employee table in sql 2005 and thought it would be cool to have an automated way to be able to build an org. chart like this
i want somethign that can be scheduled to run daily because my company has a large team and things change frequently. as an aside, i am re-fleshing the employee table (1000) records daily from Active Directory.)
anyone know a simple way to do this?
visio/ vba?
excel/ vba?
winforms/ c#?
Visio allows you to generate an org chart from a SQL database, but I'm not sure you can automate it (may have to have Visio installed on the server if you can) and it's a fair amount of work to set up the template file to lay everything out the way you like. So the short answer is "probably possible in Visio, but definitely a pain for non-Visio gurus"
In visual studio datasource designer is there any way to refresh a table and its relations/foreign key constraints while keeping the custom queries?
The way I am doing it at the moment is removing the table and adding it again. This adds all the relations and refreshes all fields.
Also if I change a fields data type, is there a way to automatically refresh all the fields in the datasource? Again without deleting the table and adding it again.
Reason for this is because some of my TableAdapters have quite a number of complex queries attached to them and when I remove the table the adapter gets removed as well including all its queries.
I am using Visual Studio 2008 and connecting to a MySQL database.
Any1 have an idea?
Each table has a default query (The one on top with the check on it). When you dragged your tables in to the dataset to create the query, it wrote a SQL statement which it uses to schema your table. Keep that query simple, you might not actually use it in code, and you can always edit that query to update the table schema.
Every time you open the default query it connects to your datasource and allows you to select new columns that weren't in there before. If you want to update your existing columns, delete all the columns out of the table before you attempt to open the query. When you save the query, your updated columns get added back.
Make sure your connection string has permissions to view column information.
I reported this to MSFT but no response. The designer hangs all the time on the simplest of SQL statements. What I found that works for me is.
Add a new table to the designer.
Save it.
Shut down visual studio 2010.
Start VS 2010.
Add one or two more SQL statements and follow steps 2-4 again.
This is a pain in the neck but the only thing that stops Visual Studio dataset designer from hanging. I experienced in this same issue in VS 2008. I am connecting to Oracle but still shutting down VS and starting it back up works, but really, this is nonsense.
You can add/change/remove fields and relation ships, but i would suggest looking into NHibernate.
You should be able to right-click the dataset in solution explorer and select "Run Custom Tool" to refresh the table and it's query/relationships.
If that command is not there, check that the dataset properties has "MSDataSetGenerator" in the Custom Tool field.
Right click on your DataSet name and select Dataset Properties
Below the Query box you will see a button for Refresh Fields.
Click on Query Designer and the new field should show in your table list.