CodeGuru Forums -
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic Newsletters VB Forums Developer.com


Newest CodeGuru.com Articles:

  • Building Interactive UIs with ASP.NET Ajax: Rebinding Client-Side Events After a Partial Page Postback
  • Speed Up Repetitive Insert, Update, and Delete Query Statements
  • Binding Data to Silverlight 4.0 Controls Using ASP.NET MVC Framework 2.0
  • ADO.NET Data Services in the .NET Framework

  • Search CodeGuru:
     



    Go Back   CodeGuru Forums > .NET Programming > C-Sharp Programming
    FAQ Members List Calendar Search Today's Posts Mark Forums Read

    C-Sharp Programming Post questions, answers, and comments about C#.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1    
    Old July 10th, 2009, 01:05 AM
    prasad_oct12 prasad_oct12 is offline
    Junior Member
     
    Join Date: Apr 2009
    Posts: 5
    prasad_oct12 is an unknown quantity at this point (<10)
    update database through datagridview

    Hello Friends,
    I am getting a problem to update the database from datagridview row.
    I am using the following code

    private void showButton_Click(object sender, EventArgs e)
    {
    con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\MoneyData.mdb");
    String query = "SELECT * FROM Categories";
    da = new OleDbDataAdapter(query, con);
    OleDbCommandBuilder cb = new OleDbCommandBuilder(da);
    ds = new DataSet();
    da.Fill(ds);
    dataGridView1.DataSource = ds.Tables[0];

    con.Close();

    }

    private void UpdateButton_Click(object sender, EventArgs e)
    {
    da.Update(ds);
    }

    if i run the code
    i am getting the following error
    "Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information."
    Please help me...
    thank you
    Reply With Quote
      #2    
    Old July 11th, 2009, 06:00 AM
    memeloo memeloo is offline
    Member +
     
    Join Date: Oct 2008
    Location: Cologne, Germany
    Posts: 618
    memeloo  is a jewel in the rough (300+)memeloo  is a jewel in the rough (300+)memeloo  is a jewel in the rough (300+)memeloo  is a jewel in the rough (300+)
    Re: update database through datagridview

    have your table a primary key?
    __________________
    win7 x86, VS 2008, C++/CLI, C#, .NET 3.5, VB.NET, VBA

    remeber to give feedback and if you think my response deserves recognition perhaps you may want to click the Rate this post link/button
    Reply With Quote
      #3    
    Old July 11th, 2009, 12:34 PM
    prasad_oct12 prasad_oct12 is offline
    Junior Member
     
    Join Date: Apr 2009
    Posts: 5
    prasad_oct12 is an unknown quantity at this point (<10)
    Re: update database through datagridview

    no , but foreign key is there for one column, but i am not updating that column....
    Reply With Quote
    Reply

    Bookmarks
    Go Back   CodeGuru Forums > .NET Programming > C-Sharp Programming


    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 02:20 AM.



    Acceptable Use Policy

    Internet.com
    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers


    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.