Wrox Programmer Forums
|
ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.x and 2.0 Application Design 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 July 30th, 2007, 12:36 AM
Registered User
 
Join Date: Feb 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default problem in inserting data

I am inserting values from a form but unable to get them added to database.I am working on .net2.0 and using sql server.getting Exception:
System.InvalidOperationException: Fill: SelectCommand.Connection property has not been initialized.

I am using this function

private void bindData()
        {

            dbcon objDbCon = new dbcon();
        
            string sql;
                    
         SqlCommand cmd = new SqlCommand("select * from products");
        
            SqlDataAdapter myDA = new SqlDataAdapter(cmd);
                    
            DataSet ds = new DataSet();
            myDA.Fill(ds, "products"); ----------Error in this line
            DataRow myRow = ds.Tables["products"].NewRow();
            myRow["cat_id"] = cat_id;
            myRow["name"] = pname;
            myRow["generic"] = gen;
            myRow["Aname"] = supname;
            myRow["indian_name"] = ind_name;
            myRow["brand"] = brnd;
            myRow["Detail"] = detail;
            myRow["heading"] = heading1;
            myRow["rate"] = price;
            myRow["pro_icon"] = Session["iconpic"];
            myRow["pro_image"] = Session["imagepic"];
            ds.Tables["products"].Rows.Add(myRow);


            SqlCommandBuilder mBuild = new SqlCommandBuilder(myDA);
            myDA.Update(ds, "products");
                objDbCon.dispose();
            objDbCon = null;
        
        }
 
Old July 30th, 2007, 02:48 AM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
Default

Well, there is nothing we could help if you post it this raw... Let us know exactly how you are inserting data, whether you are receiving any error etc etc.

Basically, elaborate your question a bit..

Regards
Mike

Don't expect too much, too soon.





Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in inserting data in gridview deb_kareng ASP.NET 2.0 Professional 0 August 22nd, 2007 02:07 AM
mysterious problem (data no inserting ) gratisaccount VB.NET 2002/2003 Basics 1 June 29th, 2006 08:48 AM
Problem with inserting data into an Access DB donrafeal ASP.NET 2.0 Basics 0 January 6th, 2006 05:34 PM
Problem inserting with data adapter cridley ADO.NET 1 February 22nd, 2005 05:02 PM
Inserting "TextArea" field's data problem phungleon Classic ASP Databases 11 August 2nd, 2004 05:19 PM





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