Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 22nd, 2005, 09:55 PM
Registered User
 
Join Date: Dec 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default datagrid editing command help plz

Right LAST Problem i have.

need to edit the data from the table:

using the code below but getting got a little bug in it i not been able to work out yet! any help would be great

code:

DBConn.OleDbConns objConn = new DBConn.OleDbConns();
            OleDbConnection objOleDbConn = objConn.OpenReadConn();
            OleDbDataAdapter myDataAdapter = new OleDbDataAdapter();
            myDataAdapter.SelectCommand = new OleDbCommand("SELECT * FROM "+dtable+"",objOleDbConn);
            OleDbCommandBuilder custCB = new OleDbCommandBuilder(myDataAdapter);

            DataSet custDS = new DataSet();
            myDataAdapter.Fill(custDS,"+dtable+");
            myDataGrid.DataSource=custDS;



        string number1, number2, number3, number4, number5, number6;




    string key = myDataGrid.DataKeys[e.Item.ItemIndex].ToString();



    TextBox tb;


    tb = (TextBox)(e.Item.Cells[3].Controls[0]);
    number1 = tb.Text;


    tb = (TextBox)(e.Item.Cells[4].Controls[0]);
    number2 = tb.Text;


    tb = (TextBox)(e.Item.Cells[5].Controls[0]);
    number3 = tb.Text;

    tb = (TextBox)(e.Item.Cells[6].Controls[0]);
    number4 = tb.Text;

    tb = (TextBox)(e.Item.Cells[7].Controls[0]);
    number5 = tb.Text;

    tb = (TextBox)(e.Item.Cells.Controls[0]);
    number6 = tb.Text;


// have the problem is here
    custDS.Tables["+dtable+"].Rows r;
    r = custDS.Tables["+dtable+"].FindBylastname(key);

    // Updates the dataset table.

    r.number1= number1;
    r.number2 = number2;
    r.number3 = number3;
    r.number4= number4;
    r.number5 = number5;
    r.number6= number6;

    // Calls a SQL statement to update the database from the dataset


    myDataAdapter.Update(custDS,"+dtable+");

    // Takes the DataGrid row out of editing mode
    myDataGrid.EditItemIndex = -1;

    // Refreshes the grid
    myDataGrid.DataBind();
            objConn.CloseConn(objOleDbConn);


getting the error that r need a ; but already got one :S ????

thanks for ur time and help

 
Old December 29th, 2005, 05:56 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

// have the problem is here
custDS.Tables["+dtable+"].Rows r;

What is that "r" in there for?

Maybe do you mean that to be:

System.Data.DataRowCollection r;

-Peter





Similar Threads
Thread Thread Starter Forum Replies Last Post
Editing Datagrid toddw607 ASP.NET 2.0 Basics 5 April 26th, 2007 03:06 PM
DataGrid Editing Problem gaurav_jain2403 .NET Framework 1.x 2 December 9th, 2006 04:33 AM
Editing in DataGrid abdul_owiusa ASP.NET 1.0 and 1.1 Professional 0 May 1st, 2006 07:56 AM
Problem with Datagrid Editing pramesh_it ASP.NET 1.0 and 1.1 Basics 0 April 17th, 2006 09:58 AM
Multiplerecord editing in Datagrid vids ASP.NET 1.x and 2.0 Application Design 0 March 10th, 2005 11:41 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.