Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics 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 April 26th, 2008, 12:44 AM
Registered User
 
Join Date: Apr 2008
Posts: 9
Thanks: 0
Thanked 1 Time in 1 Post
Default How can I store Gridview into Database?

I use gridview binding with contents of one table from oracle.It displays record in gridview well but i got problem while storing that record into another table in oracle.Remember my source for gridview and destination of store are different.So please help for that.My code like as...
DataTable dtlocal = new DataTable();
        dtlocal = (DataTable)GridView1.DataSource;
        dtlocal.TableName = "LOCAL";
        ds.Tables.Add(dtlocal);
        string qry = "INSERT INTO EMP1 VALUES(?,?,?,?)";
        conn.Open();
        OracleCommand ocmd = new OracleCommand(qry, conn);
        foreach (DataRow dtr in ds.dtlocal["LOCAL"].Rows)
            foreach (DataColumn dcl in ds.dtlocal["LOCAL"].Columns)
        {
                //assigning values for parameters
        }

Vish
 
Old April 26th, 2008, 05:04 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

What problems did you get? You have not provided any errors or descriptions of the problems. Perhaps showing us the code where you "//assigning values for parameters " would be helpful to obtaining an answer.

-Peter
peterlanoie.blog
 
Old April 26th, 2008, 07:14 AM
Registered User
 
Join Date: Apr 2008
Posts: 9
Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
quote:Originally posted by planoie
 What problems did you get? You have not provided any errors or descriptions of the problems. Perhaps showing us the code where you "//assigning values for parameters " would be helpful to obtaining an answer.

-Peter
peterlanoie.blog
My code for assigning the value as follows..
 ocmd.Parameters.Add(":p1", OracleType.Number).Value = Convert.ToInt32(dtr[dcl]);
            ocmd.Parameters.Add(":p2", OracleType.VarChar).Value = dtr[dcl];
            ocmd.Parameters.Add(":p3", OracleType.Number).Value = Convert.ToInt32(dtr[dcl]);
            ocmd.Parameters.Add(":p4", OracleType.Number).Value = Convert.ToInt32(dtr[dcl]);
            ocmd.ExecuteNonQuery();
        }
When i iterates through datatable record it give me error as Error "System.Data.DataSet' does not contain a definition for 'dtlocal'"
Plz help me to solve it.

Vish
 
Old April 26th, 2008, 08:14 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Here you name the table LOCAL:

   dtlocal.TableName = "LOCAL";

But you are trying to use a property to get at it:

   ds.dtlocal["LOCAL"]

I think what you want is this:

   ds.Tables["LOCAL"]


-Peter
peterlanoie.blog





Similar Threads
Thread Thread Starter Forum Replies Last Post
how to store checkbox value in database mona_1dec Struts 22 July 8th, 2011 04:29 PM
How to Store data from GridView to DataBase? divekar.vishal ASP.NET 2.0 Basics 0 April 18th, 2008 06:24 AM
Ho do we store pictures in a database? vitalis PHP Databases 2 March 18th, 2007 12:05 PM
store machine name in database alyeng2000 ASP.NET 1.0 and 1.1 Professional 5 September 29th, 2004 10:55 PM
Where could get the Music Store Database? cash Java Databases 2 February 21st, 2004 08:48 PM





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