#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    64
    Rep Power
    11

    Update Database with Dataadapter / Get the Value of currentcell


    I use a OleDbDataAdapter to get Data into a datagrid.

    .
    Code:
    OleDbConnection* DBConn=new OleDbConnection();
    DBConn->ConnectionString=S"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=Export.mdb;";
    
    OleDbDataAdapter* DAdapt = new OleDbDataAdapter();
    String *test=S"SELECT * FROM [XXX]";
    
    test=test->Replace(S"XXX",comboBox1->Text);
    DAdapt->SelectCommand=new OleDbCommand(test, DBConn);
    
    DataSet* DSet=new DataSet();
    DAdapt->Fill(DSet);
    
    dataGrid1->DataSource=DatenSatz->Tables->Item[0];
    How can I update the Database when the user changes Data in the datagrid?

    I thought about a way to get the value of the currentcell in the datagrid and use this value in a SQL-Update but I can not find a way how to get the value of the currentcell of the datagrid!

    I use VC++ .net and the database is an Access-database
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    64
    Rep Power
    11
    I tried something:
    Code:
    label1->Text = dataGrid1->get_Item(dataGrid1-> CurrentCell.RowNumber,dataGrid1->CurrentCell.ColumnNumber);
    But I get this error:
    error C2664: 'System::Windows::Forms::Control::set_Text': Conversion of Parameters 1 from 'System::Object __gc *' to 'System::String __gc *' not possible

    Does sombody knows how to convert this correctly?

IMN logo majestic logo threadwatch logo seochat tools logo