Take A Lot Of Time To Create Object From Database [closed] - c#

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I'm using C# and MySql trying to make a desktop application. MySql is on a server. The problem that I found is my application takes quite a while to load data from database to create object. Here is my logic. A user opens up inventory page, then the application will load all products' data from database creating object and show list of products. The application worked fine when I have less products. When I have many products in the database, the loading process takes a while. Any suggestion on logic? My logic is probably not good enough.

You should use paging to get limited data from database at most 25 then on next page 25, like this you can avoid overhead the problem of slowness

Related

C# Windows Forms - Preserving data in dynamically created objects [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'm currently working on a windows form application in C# and was wondering how to preserve data between executions? My application starts with a blank form that has a button that dynamically creates user controls, each one just containing a text box (picture a to-do list). The user has the ability to write into these text boxes, as well as dynamically delete them as well.
I've got the application all built and I can create number of objects, but I was wondering how I could save the data between closing and re-opening it. This is in VS 2015.
Much appreciated!
Essentially, you've got two options.
Store to file.
Store to DB.
Depending on your circumstances, privileges etc. you might want to call a web service and feed the state information to it. Then, upon re-launch, you just get read back from it.
Or, if that's a good option, you can simply store a local file with the information and then read from it. The exchangeability of data will suffer and you may face issues with access rights, though.
If the amount information that you need to store is fairly limited, you might simply write a few keys to the registry. The info will still be local and access needs to be granted but except for that, you'd be compartmentilize the data rather well.
In this case I would suggest making a list of your textboxes and then serializing their values and then saving into some format, let's say xml. It is possible to serialize whole list and then load it with simple code.
Edit: Maarten had a good point, I forgot about that you cannot serialize the whole component. I am assuming you are adding textboxes dynamically, so you already have some list/array of values.

Can SSRS Reports be used without a SQL Server Database? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have an application that gets all its data from an old AS400 application.
I get a model out (what in MVC I'd call a ViewModel) that has all the data for the reports, but the current legacy code is using the windows forms drawing API to place each box and label and data value on the report. It is hard-coded and maintenance is what you'd expect in terms of nightmare level.
I want to switch over to a report based on the data object or a collection thereof. I know how to write code against an object data source in ASP.Net, but I was wondering if the same can be done using SSRS for the report design, then using the objects collection as the data source. Has anyone done this?
Joey Morgan
SSRS is very extensible and you can write your own custom data processing extension that processes whatever data you have (in your case, the objects collection) and turns it into a dataset.
I've done this and while it isn't trivial, it isn't as hard as you might think and implementing a custom data processing extension may be a good way to solve your problem. There are plenty of examples online to get you started. I based mine on the file share example provided with SSRS that queries a network folder and returns the file information as a dataset.

C# How to update data in datagridview [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I am building a C# wpf SQL server application and before I start there are few things that i want to ask.
First of, the application will be used by several clients to write data into one SQL table. In the main window of the application I will have a datagridview that will display the main table. Since data is going to be entered by more than one person, can I dynamically update the datagrid view or should I use a timer and update in once every few minutes?
Is it better if I open one global SQL connection and keep it open while the application is running (and if it is how can I do that) or should I create a new connection each time I want to do something?
These are the questions for now, I am sure I will have much more questions in the progress, since I am new to wpf and database programming. Thanks for the understanding :).
I recommend you to build your wpf application in mvvm architecture.
As for me, I think you should not use timers for this purpose. Because if your client will use different filters or sortings, to find custom data rows, these sudden data updates will change displayed data order, which is an unpredictable behavior (breaks UI development principles) and it will annoy everyone. The better solution, is when users will refresh data only when they need it (manually, button click), or on navigating to dataGrid table control himself (automatically).
If a client takes a record on editing, you can store record State parameter in database, and check its state to avoid collisions (editing of the same data in the same time by multiple users).
You should not keep the connection alive explicitly, when you're not make operation with dataBase. Since you're using WPF - the best, easy to configure and managing approach - to install EntityFramework nuget package to your project, and use Code first.
Here is a good tutorials, about how to use it.
Working with your database through project models is much more reliable and simple in realization, than working through SqlConnection classes.

How to record and store data when using team foundation explorer? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am working on a C# windows forms project with a friend and we are using TFS for our source control. The program we have written scrapes data off a couple of webpages at regular time intervals and this is updated to the UI.
However, we would like to be able to store this data for future reference. We will be gathering around 1000 bits of data every few seconds for several hours a day.
I'm relatively new to programming and know very little about databases and couldn't find anything on the internet about how to use them with team foundation server. What's the best way to store this data so it is accessible to both me and my colleague?
So far, we've used local XML files but as I say we need somewhere to centrally store the data.
Sorry if there's any information you need that I've missed off - this is the first question I've asked on a forum - but let me know and I'll provide any info I can.
I look forward to your help,
There is nothing specific about TFS that would keep you from using databases.
If you have installed Visual Studio as your IDE to work with TFS as your source control you probably have a copy of SQL Server Express installed. I would look into how to utilize that. You may want to look at Linq to SQL or ADO.Net to provide your connectivity to your database from your applcation. You will likely get a great deal more flexibility and performance depending on how much data you are collecting if you keep it there vs files.
ADO.Net Tutorial
Linq to SQL Tutorials
Entity Framework
Create a .txt file and every time the service runs append a new line to the text file.
How to add new line into txt file

How to populate a dropdownlist using a stored procedure without an objectdatasource [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I am working on a web page that requires distinct user information to be displayed. several different users will be using this page, so the data will be different for each account.
This information is retrieved through stored procedures via entitymodel.
I cannot use an objectdatasource because my SP for the DDL requires an parameter(UserId) (unless there is a way to do it, in which I would not know !) The UserId is grabbed at page load via aspnet membership. this DDL also needs to be populated as the page opens up.
I have done some research on programmatically populating a DDL but cannot find any examples that tailor to what I am trying to do.
I need a general DDL to be populated(item and value) by a SP with a parameter(userId), when the page opens up.
Nothing more, nothing less :)
My question basically would be; what would be the best way to populate the dropdownlist under these circumstances
This post uses a Non-Typed-DataSet and a stored procedure to bind to a CheckBoxList which is the same principle (caveat: own blog post):
http://www.codersbarn.com/post/2008/10/12/Bind-CheckBoxList-to-DataSet.aspx

Categories