Program a Data source (Visual Studio) alike in C# - c#

I'm trying to develop a data source alike (visual studio). I have the interface all done already(easy part), but the trickies parts of this projects are:
1 - I need to populate the data source according to what the user has installed on his(her) computer, meaning that, if he doens't have Oracle, the tab won't show. -> That's the part I'm having difficult.
The binding part, I have a sketch, using ifs (or switchs) using the text in the data source field.
I'm using DevX in the interface !
Any ideas ?
Thanks

As there is no .NET API to get the list so you have to work with Windows registry to find the list.
Here is good tutorial on finding datasource name.......

Related

How to connect to LocalDB in a .NET 5 project?

I am writing a console application using .NET 5, and I am using a LocalDB instance (at least I hope that's the right terminology) to store the data that the application needs. I can see the database (including both tables and all the data in said tables) in both the Server Explorer and SQL Server Object Explorer tabs of Visual Studio 2019, but the Data Sources tab the only thing that shows is the text "This window is not supported for the selected project."
The problem is, all the tutorials I've been able to find rely on that Data Sources tab. From looking at other questions here on Stack Overflow, it looks to me like that tab is deprecated with .NET 5? Am I correct? And how would I write the code to access the database and perform CRUD operations without the Data Sources tab?
Sorry if this is a stupid question; this is my first time using LocalDB.
You should use SQL Server Object Explorer. If you right click on the database that you want to connect, you can see the properties, including connection string. If you have trouble with incorporating Connection string into your code - you need to show the code and the problem.
Whether Data Sources is deprecated or not, as you can see it is not supported for most projects (I think it's just for Windows projects - but I may be wrong). Anyway - you don't need it. And by the way - this approach works regardless of the database you use (LocalDB, SQL Express or regular SQL Server)

C# code for Grid to FoxPro DBF (free table)

What is the easiest way (without installing extra drivers) to open a FoxPro DBF table and link it to a DataGrid in WPF?
I guess this as nothing do do specificaly with WPF. You can link almost any .net collection/data collector object to WPF data grid.
But your problem stands way before that and concerns .net data access in general. You should remove the WPF tag from your question and rather see what ADO. net can do for you.
Once this is done and that you have the content of your FoxPro db in a .net collection, then you will worry about WPF ;)
i don't think this is possible without driver installation. see this question.
There are ways to do it without installing new drivers but none if them are easy.
You could inspect the table at the file level - the structure is documented here: http://fox.wikis.com/wc.dll?Wiki~TableFileStructure
Or you could write a VFP exe that you can run from your C# code that dumps the table to XML. See the CURSORTOXML function for more details.
Written on my iPhone.
Do you know how to use basic ADO.Net to connect to a FoxPro DBF table and create a Typed DataSet? That's the first step you've got to get working. From there, the task becomes binding a WPF DataGrid to a Typed DataSet.

How should I go about creating a multilingual text translation editor in VS 2010?

Feature explained below is available in Microsoft Dynamics AX (formerly known as Axapta), an ERP application. However, my question is related to Visual Studio 2010 and MVC 3 application. Please find my questions after this feature explanation.
Screenshot #1 shows a method written in X++ (language used in Microsoft Dynamics AX) using the MorphX editor. If I select a text within double quotes and right-click on them, I will get the options as shown in the screenshot. This is true if the text begins with an # character and is a valid id found in the label file.
If I click on the option Lookup Properties/Methods, a tool tip will appear showing the actual text associated with the selected label id. Here in this case the label id is #SYS67 and its associated label text is Transaction date. Refer screenshot #2.
If I click on the option Lookup Label/Text, the label editor will appear with the label id pre-filtered along with other languages of choice at the bottom section of the editor. I can change the translation text in different languages using the editor. Refer screenshot #3.
In Dynamics AX, the label texts are stored in text files with label id and separated by a tab. Label ids always begin with # symbol. Here in the example shown #SYS is the group prefix and the given number is a sequential index. Refer screenshot #4 that displays text found in an en-us label file.
I understand that this is similar to Resource editor in Visual Studio where the translation text are stored in .resx files for each language. I would like to do something similar for an ASP.NET MVC 3 application using SQL Server database as the data store for the translation text.
Here are my questions:
What would I need to create in Visual Studio 2010 to achieve this functionality so I can invoke the translation editor in the IDE? Would that be a plugin or extension?
Would a similar resource provider be possible to do in an ASP.NET MVC application, where I can just specify the label id within double quotes and have provider model fetch the data from database during runtime? Is the syntax Resources.MyResource.GetLabel("#SYS67"); the only available option in ASP.NET? Sorry, if the resources syntax is wrong.
Are there any similar tool set (plugin/extension) already available for Visual Studio?
I believe that one of the terms to do translation in ASP.NET application is making use of Resource Provider Model. Are there any other terms? I am interested to know the term of what I am trying to achieve so I can search on the web to read more about it.
Any inputs will be really appreciated.
Thanks in advance.
Screenshot #1:
Screenshot #2:
Screenshot #3:
Screenshot #4:
I'm going to jump in here and give you what I know. I apologize if it doesn't completely answer your question but I don't want to stray too far from what I am familiar with and thus give you bad advice.
From the way you describe your issue, it seems that you could use the resource files (RESX) for translations, the issue is more that you want to know how to edit them in a manner that is user friendly. Further, some users may want to edit the translations on the web.
To answer this part of your question, I would recommend that you look at this article:
http://blog.lavablast.com/post/2008/02/07/RESX-file-Web-Editor.aspx
The author seems to have a similar issue as you and the conclusion the author arrived at was similar to what you are thinking about. The source code is provided so you could get a head-start if you wanted to pursue this method.
If you are going to pursue rolling your own editor, I would suggest that you choose one interface and stick with it. Otherwise you will be increasing your development time on something that isn't your actual product. Since you want the web for some users, I would suggest you would stick with the web for everyone. However, if you really want to pursue an plugin for Visual Studio, I would recommend that you put as much code into a central business logic layer as possible so that your presentation layers don't take up much of your time.
As for currently-available options, I don't think any of the following are Visual Studio plugins, but they all do a good job at working with localization:
http://www.redpin.eu/index.html
http://www.lingobit.com/products/index.html
http://www.sdl.com/en/language-technology/products/software-localization/sdl-passolo.asp
If you want to learn more about the terminology and practices of localization, I would recommend the following site:
http://quickstarts.asp.net/QuickStartv20/aspnet/doc/localization/localization.aspx
If you want to store information in a database instead of a .resx file, here is a resource that will show you how to do it:
http://msdn.microsoft.com/en-us/library/aa905797.aspx

How to make a quick interface to edit / delete / add the database?

I have the database mysql.
I need to access it via a desktop application with the ability to change does not have value.
in asp.net is there, this dynamic data filter, I need the same thing but in WPF.
Visual Studio has lots of easy tools to help you integrate your SQL Server into the application from using things like the DataGridView to the DataRepeater take a look at this article http://www.codeproject.com/KB/WPF/wpfviews.aspx it should help you get started. Using LINQ to assist in speed application development.
Another Great link: http://dotnetslackers.com/articles/wpf/WPFDataBindingWithLINQ.aspx

Using Crystal Reports in Visual Studio 2005 (C# .NET Windows App)

I need to create reports in a C# .NET Windows app. I've got an SQL Server 2005 database, Visual Studio 2005 and am quite OK with creating stored procedures and datasets.
Can someone please point me in the right direction for creating reports? I just can't seem work it out. Some examples would be a good start, or a simple How-to tutorial... anything really that is a bit better explained than the MSDN docs.
I'm using the CrystalDecisions.Windows.Forms.CrystalReportViewer control to display the reports, I presume this is correct.
If I'm about to embark on a long and complex journey, what's the simplest way to create and display reports that can also be printed?
I have managed to make this work now.
Brief Overview
It works by having a 'data class' which is just a regular C# class containing variables and no code. This is then instantiated and filled with data and then placed inside an ArrayList. The ArrayList is bound to the report viewer, along with the name of the report to load. In the report designer '.Net Objects' are used, rather than communicating with the database.
Explanation
I created a class to hold the data for my report. This class is manually filled by me by manually retrieving data from the database. How you do this doesn't matter, but here's an example:
DataSet ds = GeneratePickingNoteDataSet(id);
foreach (DataRow row in ds.Tables[0].Rows) {
CPickingNoteData pickingNoteData = new CPickingNoteData();
pickingNoteData.delivery_date = (DateTime)row["delivery_date"];
pickingNoteData.cust_po = (int)row["CustomerPONumber"];
pickingNoteData.address = row["CustomerAddress"].ToString();
// ... and so on ...
rptData.Add(pickingNoteData);
}
The class is then put inside an ArrayList. Each element in the arraylist corresponds to one 'row' in the finished report.
The first element in the list can also hold the report header data, and the last element in the list can hold the report footer data. And because this is an ArrayList, normal Array access can be used to get at them:
((CPickingNoteData)rptData[0]).header_date = DateTime.Now;
((CPickingNoteData)rptData[rptData.Count-1]).footer_serial = GenerateSerialNumber();
Once you have an arraylist full of data, bind it to your report viewer like this, where 'rptData' is of type 'ArrayList'
ReportDocument reportDoc = new ReportDocument();
reportDoc.Load(reportPath);
reportDoc.SetDataSource(rptData);
crystalReportViewer.ReportSource = reportDoc;
Now you will need to bind your data class to the report itself. You do this inside the designer:
Open the Field Explorer tab (which might be under the 'View' menu), and right-click "Database Fields"
Click on 'Project Data'
Click on '.NET Objects'
Scroll down the list to find your
data class (if it isn't there,
compile your application)
Press '>>' and then OK
You can now drag the class members
onto the report and arrange them as
you want.
Crystal is one possible option for creating reports. It has been around a long time and a lot of people seem to like it.
You might want to take a look at SQL reporting services. I have used both but my preferance is SQL reporting services. Its pretty well integrated into studio and works similar to the other microsoft projects. Its also free with the sql express etc.
This is a good article on beginning reporting services:
http://www.simple-talk.com/sql/learn-sql-server/beginning-sql-server-2005-reporting-services-part-1/
You can use the report viewer with client side reporting built into vs.net (ReportBuilder/ReportViewer control). You can create reports the same way as you do for sql reporting services, except you dont need sql server(nor asp.net). Plus you have complete control over them(how you present, how you collect data, what layer they are generated in, what you do with them after generating, such as mailing them, sending to ftp, etc). You can also export as PDF and excel.
And in your case building up a report from data and user input, this may work great as you can build up your own datasource and data as you go along. Once your data is ready to be reported on, bind it to your report.
The reports can easily be built in Visual Studio 2005 (Add a report to your project), and be shown in a Winforms app using the ReportViewer control.
Here is a great book i recommend to everyone to look at if interested in client side reports. It gives a lot of great info and many different scenarios and ways to use client side reporting.
http://www.apress.com/book/view/9781590598542
I second alex's recommendation to look at sql reporting services - if you have a sql developer license, then you probably already have reporting services
i don't like crystal reports, too much tedium in the designer (editing expressions all the time) too many server-deployment issues (check those license files!)
I use Crystal. I will outline my method briefly, but be aware that I'm a one man shop and it may not translate to your environment.
First, create a form with a CR Viewer. Then:
1) Figure out what data you need, and create a view that retrieves the desired columns.
2) Create a new Crystal report using the wizard giving your view as the source of the data.
3) Drag, drop, insert, delete, and whatever to rough your report into shape. Yes, it's tedious.
4) Create the necessary button click or whatever, and create the function in which to generate the report.
5) Retrieve the data to a DataTable (probably in a DataSet). You do not have to use the view.
6) Create the report object. Set the DataTable to be the DataSource. Assign the report object to the CR Viewer. This is one part for which there are examples.
Comments:
If you lose the window with the database fields, etc (Field Explorer), go to View/Document Outline. (It's my fantasy to have Bill Gates on a stage and ask him to find it.)
The reason for setting up the view is that if you want to add a column, you revise the view, and the Field Explorer will update automatically. I've had all sorts of trouble doing it other ways. This method also is a work-around for a bug that requires scanning through all the tables resetting which table they point to. You want to hand Crystal a single table. You do not want to try to get Crystal to join tables, etc. I don't say it doesn't work; I say it's harder.
There is (or was) documentation for the VS implementation of Crystal on the Business Objects web site, but I believe that it has disappeared behind a register/login screen. (I could stand more info on that myself.)
I've had trouble getting Crystal to page break when I want, and not page break when I don't want, etc. It's far from the best report writer I've ever used and I do not understand why it seems to have put so many others out of business. In addition, their licensing policies are very difficult to deal with in a small, fluid organization.
Edited to add example:
AcctStatement oRpt = new AcctStatement() ;
oRpt.Database.Tables[0].SetDataSource(dsRpt.Tables[0]);
oRpt.SetParameterValue("plan_title",sPlanName) ;
crViewer.ReportSource = oRpt ;
I found the following websites solved my problems. Included here for future reference.
CrystalReportViewer Object Model Tutorials for the tutorial on how to make the whole thing work. And also Setting up a project to use Crystal Reports
and specifically preparing the form and adding the control
i think this may help you out
http://infynet.wordpress.com/2010/10/06/crystal-report-in-c/
I strongly recommend trying an alternative reporting solution - I have a lot of experience with Crystal, and have managed to do some funky things with it in .Net, but quite honestly the integration of Crystal and .Net is an absolute pig for anything but the simplest cases.
I have tried RS. I am converting from RS back to Crystal. RS is just too heavy and slow (or something). There is no reason to have to wait 30 seconds for a report to render is RS when Crystal does it in under a second.

Categories

Resources