Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8823201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:17:38+00:00 2026-06-14T06:17:38+00:00

I read SQL Command Builder class from http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommandbuilder.aspx and I found that I can

  • 0

I read SQL Command Builder class from
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommandbuilder.aspx and I found that I can show update done on dataset/database using select and update command.

SQL Command Builder concept is clear if I am using single dataset but what if I want to use two different dataset?

Scenario: I am reading values from database into one dataset ds1; which is assign to sql adapter and sql command builder. Now, I am reading only selected values from ds1 and storing into second dataset ds2; which is not assign to sql data adapter and sql command builder.

I am concern if I am updating any data on ds2 whether it will update database or not. Also, how should I do it using SQL Command builder and SQL Adapter.

//primary dataset

ds = new ProductDataSet();
        command = new SqlCommand(
            "SELECT no, name, price, cost, dept FROM PRODUCTS", connection);
        adapter = new SqlDataAdapter();
        adapter.SelectCommand = command;            
        adapter.Fill(ds, "table");

Primary dataset is fill on form load event. User will enter item no of his choice which will be search from primary ds and saved/display onto 2nd ds (2nd ds is not connected with with any adapter or command builder right now). For eg; 2nd ds have 3 items.

Now say user update any information on 2nd ds it should automatically update database and display on grid.

//2nd ds2 update code

for (int i = 0; i < ds2.Tables[0].Rows.Count; i++)
                            {
 string item = ds2.Tables[0].Rows[i][0].ToString();                   

command = new SqlCommand("UPDATE PRODUCTS SET " + _colName + " = '" + _newValue + "'" + "WHERE ITEM_NO = '" + item + "'", Class1.conn);                                    
datagrid.DataSource = ds2.Tables[0];

}

According to your suggestion if I am adding/declaring adapter/builder in above code it doesn’t work. I am getting Table Mapping error.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T06:17:39+00:00Added an answer on June 14, 2026 at 6:17 am

    Use another SQLAdapter and SQLCommandBuilder. The example on that page shows how to update your database. You just need to supply the fields to be updated in the form of a query, such as:

    SELECT Name, Address, Phone, Email FROM Contact
    

    and the command builder will generate the proper SQL UPDATE statement.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to read data from SQL Server database using Perl and the DBI
Is it possible to enforce read only permissions using the System.Data.SqlClient code accessing a
I'm using Excel 2010 to read some SQL data using an ODBC data connection.
I have a SQL Server database which I can read from, is there a
I need to read data from an Excel sheet as part of a data
I did sql command with SqlDataReader but I had this error System.IndexOutOfRangeException: UserName Page
I'm running the following SAS command: Proc SQL; Delete From Server003.CustomerList; Quit; Which is
When a SQL client issues the following command: select * into tbl2 FROM tbl1
I m testing how to retrieve data from SQL Server in Web Service. I
I've been using SqlDataReader to read results from my querys to an SQL server

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.