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 6563225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:48:17+00:00 2026-05-25T13:48:17+00:00

This may seem trivial but every example I’ve ever seen of ADO.net almost always

  • 0

This may seem trivial but every example I’ve ever seen of ADO.net almost always has a ‘fill’ before an ‘update’. We really don’t want to fill a dataset that may have 1000’s of blobs, we just want to add(insert) to the table. Is fill required for an update?As an example here’s sample code from MSFT’s web site (we’re doing something similar):

SqlConnection con = new SqlConnection("Server=Darkover;uid=<username>;pwd=<strong            password>;database=northwind");
SqlDataAdapter da = new SqlDataAdapter("Select * From MyImages", con);
SqlCommandBuilder MyCB = new SqlCommandBuilder(da); // What does this even do?
DataSet ds = new DataSet("MyImages");

da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
FileStream fs = new FileStream(@"C:\winnt\Gone Fishing.BMP", FileMode.OpenOrCreate, FileAccess.Read);

byte[] MyData= new byte[fs.Length];
fs.Read(MyData, 0, System.Convert.ToInt32(fs.Length));

fs.Close();

da.Fill(ds,"MyImages");  // are they really filling a dataset with all those images???

DataRow myRow;
myRow=ds.Tables["MyImages"].NewRow();

myRow["Description"] = "This would be description text";
myRow["imgField"] = MyData;
ds.Tables["MyImages"].Rows.Add(myRow);
da.Update(ds, "MyImages");

con.Close();
  • 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-05-25T13:48:17+00:00Added an answer on May 25, 2026 at 1:48 pm

    You want the call to da.Fill() in order to get the schema for the MyImages table. That way you can use the DataRow returned by the call to NewRow() with the correct schema (columns, keys, etc) when assigning values to the columns.

    You can tell the SqlDataAdapter to return only the schema with no data by setting the SqlDataAdapter.FillCommandBehavior:

    da.FillCommandBehavior = CommandBehavior.SchemaOnly;
    da.Fill(ds,"MyImages"); // Just get the schema for MyImages
    
    DataRow myRow = ds.Tables["MyImages"].NewRow();
    myRow["Description"] = "This would be description text";
    myRow["imgField"] = MyData;
    ds.Tables["MyImages"].Rows.Add(myRow);
    
    da.Update(ds, "MyImages");
    

    You can alternatively use da.FillSchema(), with either a single DataTable or a DataSet if your query returns multiple tables.

    DataTable dt = new DataTable();
    
    da.FillSchema(dt, SchemaType.Mapped);
    
    DataRow myRow = dt.NewRow();
    myRow["Description"] = "This would be description text";
    myRow["imgField"] = MyData;
    dt.Rows.Add(myRow);
    
    da.Update(dt);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This may seem a trivial question, but it's one that's bothered me a lot
This question may seem trivial, but I hope you won't ignore it. Before destroying
This may be something common and trivial, but I seem to be having trouble
This may seem trivial, but I can't figure it out how to 1) retrieve
This may seem trivial for most people but I am getting problems in determining
this may seem trivial but i can't figure out why DNN reports this error,
This may seem trivial but I have no idea how and the lack of
This may be trivial, but I seem to continuously run at a wall and
this may seem trivial but I'm setting up, on a profile form page I'm
This may seem kind of homework-ish and/or trivial, but it is for a real

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.