Question

Asked on 2010-10-08 at 04:39:11ID: 26680318

inserting data into orcale table from a gridview control

by: SirReadAlot500

Rating6.4Good

Hi Experts,

could u guide me thru this pls:

1)items are displayed on a gridview control say 10 records
2)user clicks on inserts so that ALL items are imported into an oracle table (whilst calling a procedure)

when testing i deleted two records from the table
3)when i click on insert button again i expert to see 10 records and not 8

any suggestions pls, am i commiting too early on the oracle side?

protected void btnAnonyCourse_Click(object sender, EventArgs e)
    {
        OracleConnection con = null;
        OracleCommand cmd = null;
        try
        {
            con = new OracleConnection("Data Source=; User ID=;Password=");
            cmd = new OracleCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Connection = con;
            cmd.CommandText = "GEN_ANONY_ID_COURSECODE";
            con.Open();
            foreach (GridViewRow row in gvAcademy.Rows)
            {
                // if (row.RowType == DataControlRowType.DataRow)
                {
                    string studRef = ((Label)row.FindControl("lblStudRef")).Text;
                    cmd.Parameters.Add("va_S_STUDENTREFERENCE", studRef).DbType = DbType.String;
                    cmd.ExecuteNonQuery();
                    cmd.Parameters.Clear();
                    lblMsg.Text = "Anonymous IDs by Course have been generated successfully";
                }
            }
        }
        catch (Exception ex)
        {
            lblMsg.Text = "<b>Message:</b> " + ex.Message;
        }
        finally
        {
            cmd.Dispose();
            con.Dispose();
        }
    }
   
==============================
CREATE OR REPLACE PROCEDURE HE_REPORTING_DATABASE.GEN_ANONY_ID_COURSECODE

(va_S_STUDENTREFERENCE IN VARCHAR2)

AS

BEGIN

INSERT INTO HE_STORE_ANONYMOUS_ID
    (P_ID,
   S_STUDENTREFERENCE,
   M_REFERENCE,
   M_NAME,
   MI_ILRA11X1,
   VC_NAME,
   S_LEGACY,
   M_START,
   M_END,
   M_CLOSE,
   P_SURNAME,
   P_FORENAMES    
   )
SELECT   P_ID,
   S_STUDENTREFERENCE,
   M_REFERENCE,
   M_NAME,
   MI_ILRA11X1,
   VC_NAME,
   S_LEGACY,
   M_START,
   M_END,
   M_CLOSE,
   P_SURNAME,
   P_FORENAMES  
FROM HE_GET_ANONYMOUS_ID
WHERE   S_STUDENTREFERENCE = va_S_STUDENTREFERENCE
  AND NOT EXISTS( SELECT NULL FROM HE_STORE_ANONYMOUS_ID WHERE S_STUDENTREFERENCE = va_S_STUDENTREFERENCE );

COMMIT;

End GEN_ANONY_ID_COURSECODE;
/
                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:

Select allOpen in new window

Related Solutions

Solution

Sign up now to view this solution! It's quick, easy, and secure to subscribe. We will return you to this solution, unlocked, when you’re done.

About this Solution
View This Solution - Start Your 30 Day Free Trial
Zone
Oracle 09
Tags
Participating Experts
2
Solution Grade
B

Replies

 by: kris_per

Posted on 2010-10-08 at 05:30:01ID: 34349620

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: sdstuber

Posted on 2010-10-08 at 06:36:05ID: 34349621

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: SirReadAlot

Posted on 2010-10-08 at 06:37:45ID: 34349622

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: SirReadAlot

Posted on 2010-10-08 at 06:41:16ID: 34349623

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: SirReadAlot

Posted on 2010-10-08 at 06:45:35ID: 34349624

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by:

Posted on 2010-10-08 at 07:18:08ID: 34349625

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: SirReadAlot

Posted on 2010-10-08 at 07:23:26ID: 34349626

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: kris_per

Posted on 2010-10-08 at 07:28:20ID: 34349627

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: sdstuber

Posted on 2010-10-08 at 07:28:39ID: 34349628

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: sdstuber

Posted on 2010-10-08 at 07:29:17ID: 34349629

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: sdstuber

Posted on 2010-10-08 at 07:31:21ID: 34349630

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: sdstuber

Posted on 2010-10-08 at 07:53:38ID: 34349631

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: kris_per

Posted on 2010-10-08 at 14:34:39ID: 34349632

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: SirReadAlot

Posted on 2010-10-28 at 05:17:43ID: 34349633

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

Stay Connected

Oracle Around the Web

The latest Oracle news, tips, and tricks

Oracle Unveils Netra SPARC T3 Servers

New Carrier-Grade Blade and Rackmount Servers Deliver Better Performance, Density and Power Efficiency for the Communications Industry ...

read more

Oracle fixes 21 flaws in Java SE, Java for Business

Oracle is fixing 21 flaws in its Java SE and Java for Business products in its February critical patch update issued this week ...

read more

Obama’s Silicon Valley “Tech Supper”

Why was he there? Who wasn’t invited and why? What did they talk about? Why was he really there? These are the questions being debated ...

read more

Featured Oracle Experts

slightwv

slightwv has answered more than 2,000 Oracle questions and oversees database management within the U.S. Government. Slightwv

sdstuber

A regular presenter at the Collaborate conference, Oracle developer sdstuber is a top expert in PL/SQL and Oracle 9, 10 and 11. sdstuber

Testimonials

What users are saying about our experts

"The Oracle gurus provide answers, solutions and valuable workarounds"

User: schwertner

"Wow! Excellent, valuable explanation. Hats off to you"

User: aseshu70

"Solution worked fantastic and performs excellent! Thanks heaps"

User: klausbrandlhuber

Top Experts

Know a thing or two about Oracle? Join our team of experts today.

    BrowseBecome an Expert