Reputation: 780
In datagrid using C# while updating the sqlite from the form application I am getting index out of range exception .
Cannot find table 0
Below is my code
SQLiteConnection connection4 = new SQLiteConnection
(@"Data Source = C:\APTRABuilder.sqlite;Version =3");
connection4.Open();
string sql2 = "Update table set language1= '"
+ textBoxUpdate1.Text + "' where language2 = '"
+ textBox_Search.Text + "'";
SQLiteDataAdapter connect4 = new SQLiteDataAdapter(sql2, connection4);
DataSet ds4 = new DataSet();
connect4.Fill(ds4);
dataGridView.DataSource = ds4.Tables[0];
Error I am getting in dataGridView.DataSource = ds4.Tables[0];
Upvotes: 0
Views: 875
Reputation: 8640
You need to look at creating an UPDATE command for your Data Adapter.
You will also need to learn about adding values with Parameters.
Rather than trying to Fill the DataAdapter you are required to UPDATE the DataAdapter in this scenario. When you Fill a DataAdapter, you are populating the Adapter. To do this you use a SELECT command. These two methods are entirely different.
This Guide below will get you started in understanding Data Adapters better :-
http://msdn.microsoft.com/en-us/library/33y2221y.aspx
Good Luck.
Upvotes: 1
Reputation: 152644
There are no tables in the DataSet
becasue the SQL is doing an UPDATE, not a SELECT, so there are no results to return.
Upvotes: 1