referring to controls....

Associate
Joined
27 Jan 2005
Posts
1,396
Location
S. Yorks
I am having a total brain fart with this...

I have a form with 22 datagrid controls on it, they are populated from an Access database. I am wanting to read the data from the datagrid controls, the Access database provides base data that the user may want to modify, but I can't for the life of me think how to do it

regards,

Matt
 
I think the problem lies in that I dont think you can directly read/write the data as the datagrid view is just a view. When I was wanting to read and write to the database I had to make a series of different sql commands. For example,
Code:
private: void insertRowIntoDB(String^ modVal)
{
   try{
          String^ connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=database.mdb";
          OleDbConnection^ myConnection = gcnew OleDbConnection(connectionString);
          OleDbCommand^ myCommand = gcnew OleDbCommand("INSERT INTO `tableName` (`column1`, `column2`, `column3`, `column4`) VALUES ( "+modVal+", 0, 0, 0,)", myConnection);
          myConnection->Open();
          myCommand->ExecuteNonQuery();
          myConnection->Close();
       }
       catch(...)
       {
       }
}

This code will open a connection to the database and write a new row to the database with modVal in columnOrdinal 1. Obviously different sql commands can be used to do different things - im not sure of your level of proficiency sorry if you know all this already. I guess you could read the value entered by the user at a position in the dataView and feed the corresponding row/column and value into a function to use a command to actually modify the database. Hope this is of some value :)
 
Last edited:
Not quite sure what you're after but you can edit and update data in a datagrid with an EditCommandColumn, just refer to MSDN
 
just read the data out of the dataset/datatables that you are using to populate the grid no? And 22 grids.. I suspect your design skill could be a bit dodgy lol.
 
Back
Top Bottom