I made a Winforms application that displays rows of data in a DataGridView. I want to add a function that searches for specific rows based on text that the user enters in a Textbox. I have found examples that use SQL queries but I did not construct my DataGridView from an SQL database data source, I filled in each row manually one-by-one with strings and ints.
https://www.c-sharpcorner.com/UploadFile/1e050f/search-record-in-datagridview-C-Sharp/
I am new to databases and I have a conceptual question. Can I create a temporary database at runtime without needing to install a password-protected database onto my system? This program is one that I share with colleagues as an .exe file and I don't want them to need to download and install an SQL database with a specific username/password just to run the program. I don't want the data stored in the database to persist when the program exits. I just want to be able to create a database and query it so I can implement a good search function for my DataGridView while the program is actually running. My program generates a completely new DataGridView at runtime based on the .txt log file that the user provides and has no need for data to persist between runs.
You don't need a Database behind your program to filter your DataGridView.
Instead of generating the DataGrid directly:
retrieve and save your data in a separate list
Filter the list using Linq and save the filtered result in a query
apply the query result to your DataGridView DataSource
Related
We use an MS SQL database directly as a data source for List & Label. All tables, columns and data records are then always available at once.
However, a created report should not always display all data, so we have selected the appearance condition within the report in such a way that only certain data of a table is displayed.
But we don't want to create and offer a separate report for each possible condition in a table, where each one has its own appearance condition. Also the user should not be able to change the report itself in the designer. Is there a simple and user-friendly way that the user can decide from "outside" for the report which data should be displayed?
The best way to achieve this is using a report parameter. You can configure them from Project > Report Parameters:
As you can see from the screenshot, the data for the report parameter can come from the database, but you can also offer a choice from a predefined list of entries or even allow the user to freely type a text. There are date pickers for date values etc.
These parameters are shown above the preview in desktop apps. In web apps, you have a separate pane - see the "Chart With Report Parameters" sample here.
Once you have configured the parameter as required, use it in the "Data Filter" property of your report container items. Note that you should look for a filter that translates to your database's syntax. This blog article has more details on the concept.
I have a small website with couple different forms inserting data to sql. But the users have problem with it. The problem is that they seem to be going through them too fast that its not recording everything.
So i am trying to see if there was a way to store all the data locally and have it insert to sql at the end when they are done filling out forms. Is this possible?
For example:
I have a form that have 5 fields but 2 are auto populated and 1 entered manually and 2 are being inserted using bar code scanner. The bar code scanner is the last value required before being inserted, so i was hoping there was a way to insert that into locally store access database (not seen by anyone) and when they press "Finish" all that data from access will be inserted into sql.
Hope i painted the picture clear enough.
Let me know any and all possibilities.
EDIT: Here is the aspx and .cs, hope this helps. Yes i realize that i have validation for the bar code, but not sure why its slow. And i may have stuff cluttered. So please bear with me.
Sounds like you need to put that data in application session or cache and then flush the data to db.
Here are some other choices though:
Flat files (simply serialize your objects, use protobuf)
Use Embeded Db: SqlLite, VistaDb, Sql Server Compact...
Store data in the browser via localstorage (dom storage, this is html 5 feature)
After a few failed attemps of integrating the existing Web based sql table editors to my solution, I have decided to write my own Web Based Sql Server table editor and I am thinking of using Gridview control for all the online processes on my database, here my questions:
1- Does Gridview a complete solution for SQL Server Database Table
Editor ?
2- Does Gridview the best way to do this?
P.S: What I am tring to do is creating an online admin panel of my application for an end user.
Couple of grid views and additional objects (for image viewing for example) should be enough for basic data editing.
GridView will allow you to view and edit most fields (except binary and images) from SQL table so in this respect it would work. With lookup tables you would need to use another grid view, maybe in read-only mode. It depends what you expect to have in your table editor.
You can use a sqldatasource control bound to a gridview for each table you need to manage. Sqldatasource will create CRUD operations with a wizard and Gridview will generate columns and commands automatically.
As above, you will work a bit to manage images properly, but all other fieldtype can be managed on the fly.
Datagridview is capable of operations in tables in a web interface, however auto creating a datagridview table when there is a new table added to the database is the hard part. For that reasion creating such an admin menu needs hard working, however if there won't be so much table in the application, you can create your admin panel manually with datagridviews instead of writing an own sql table editor tool.
Problem:
SQL Server table is vertical grid with options, i want the same thing to be done in asp.net with c#,
i want to connect the system with the table, it will fetch table column names with check boxes on front, and when we would check or uncheck, the value would be stored in sql server table, as we edit using SQL Server management studio, i want the same component vertically integrated into my web application. Please let me know, can we use grid vertically or there is some control for this?
You will have to iterate through the properties of the table you want. Display this information in a format that you like, and then write various small queries to edit whatever you want to be editable.
http://www.codeproject.com/KB/database/DatabaseSpy_CS.aspx
http://www.sqlrecipes.com/sql_questions_answers/how_get_table_structure_via_sql-92
http://www.google.com/search?ie=UTF-8&q=SQL+Table+Structure+c%23
I searched StackOverFlow.com for my issue, but could not find any similar/related solution.
I have few tables in SQL Server 2005, and have to make use of those tables in my Winform/C# application which is supposed to be an Admin Application where the Administrator will:-
1.Add/Edit users
2.Assign Roles
3.Assign Privileges
4.Zone Assignment
5.Area Assignment
6.Town Assignment
The result of each of these is coming from a minimum of two tables(of SQL Server DB), and this result has to be populated in each individual DataGridView of a TabControl's each TabPage.
The Administrator will first see the results, and then he/she can modify the values via the SelectedRow of the DataGridView, and in response this modification will be updated in the Database(i.e. SQL Server).
Since I am new to programming, my question is that I want to use an
SQL Server View, to get all this stuff done, but haven't used the View in connection to the DataGridView.
Although I am able to populate the single DataGridView from the SQLServer Binded DataSource, but this works only for a single DataGridView, I need to have the data for all the concerned DataGridViews in a single step.
Can anybody tell me how to do this?
If there is any other efficient solution to this, kindly reply.
NOTE:I am using Microsoft Enterprise Library, so would not use any In-Line SQL Queries.
For reference I am attaching the following link with Images.
link text
From what I remember, your Binded DataSource has to be from a single table in SQL. Have you tried representing the data differently? A drill-down to related data instead of showing it all in the same dataset would be your best solution.