Click here to Skip to main content
15,885,782 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
hi! First of all I need know how Can ı do select delete and update operation on Datagrid shortcut.

I fill data like this

C#
sql_cmd = sqLiteConnection1.CreateCommand();
            string CommandText = "Select * From PLU";
            DA = new SQLiteDataAdapter(CommandText, sqLiteConnection1);
            DS4.Reset();
            DA.Fill(DS4);
            DT = DS4.Tables[0];
            dataGridView4.DataSource = DT;
            sqLiteConnection1.Close();


DA:DataAdapter, DS4:DataSet, DT:DataTable

Can anybody help me?
Posted
Comments
Sergey Alexandrovich Kryukov 27-Mar-13 10:16am    
How about just reading the MDSN documentation on this control?
—SA
OsmanAydogan 27-Mar-13 10:52am    
What MSDN Documentation?
Sergey Alexandrovich Kryukov 27-Mar-13 10:56am    
Did you ever pressed F1 for help? :-)
—SA
OsmanAydogan 27-Mar-13 11:01am    
Come on!:D
Sergey Alexandrovich Kryukov 27-Mar-13 11:08am    
OK, your English is good enough :-)
Than you know what is MSDN documentation, right. Why not using it?
—SA

Your question is not well-formed and it's hard to answer it...

Quote:
The DataGridView control[^] provides a powerful and flexible way to display data in a tabular format. You can use the DataGridView control to show read-only views of a small amount of data, or you can scale it to show editable views of very large sets of data.

You can extend the DataGridView control in a number of ways to build custom behaviors into your applications. For example, you can programmatically specify your own sorting algorithms, and you can create your own types of cells. You can easily customize the appearance of the DataGridView control by choosing among several properties. Many types of data stores can be used as a data source, or the DataGridView control can operate with no data source bound to it.

More about: DataGridView class[^]
DataEntry in the DatagridView control[^]

So, you can't "select delete and update operation on Datagrid shortcut" - whatever it means.

To manipulate data, you need to use ADO.NET[^].
Quote:
ADO.NET separates data access from data manipulation into discrete components that can be used separately or in tandem. ADO.NET includes .NET Framework data providers for connecting to a database, executing commands, and retrieving results.


More about:
Overview of ADO.NET[^]
Writing Common Code for .NET Framework...[^]
ADO.NET Sample Application[^]

Please, read these articles, then ask a question again (if any).
 
Share this answer
 
Hi,

First I want to say that the better way to do what you need is with the dataset (XSD) object.
You can add one threw the add -> new item... and then chose dataset.
In the past I did it like you do now but it is much easier to manage the tables and their boundings (datagrid, combobox, etc') with the dataset.

Second the code that you look for is this:
SQL
SqlCommandBuilder b = new SqlCommandBuilder(_sdataadapter);
_sdataadapter.Update(_sdatatable);


After you do all the things you need (add, update , delete) run this and it will update your data base.

usually it is preferred to do those operation separately it works fine together,
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900