473,388 Members | 1,298 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

ASP.NET C# - Updating Oracle database

i had written this to update data in table but its not responding
can u please help ma?
Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Web;
  5. using System.Web.Security;
  6. using System.Web.UI;
  7. using System.Web.UI.WebControls;
  8. using System.Web.UI.WebControls.WebParts;
  9. using System.Web.UI.HtmlControls;
  10. using System.Data.OleDb;
  11. using System.Data.OracleClient;
  12. public partial class _Default : System.Web.UI.Page
  13. {
  14.     OracleConnection objcon= new OracleConnection("Data Source=fsoft;user=fcctest;password=fcctest");
  15.     OracleCommand objcmd = new OracleCommand();
  16.     protected void Page_Load(object sender, EventArgs e)
  17.     {
  18.  
  19.     }
  20.     protected void Button1_Click(object sender, EventArgs e)
  21.     {
  22.         objcon.Open();
  23.         OracleDataAdapter objda = new OracleDataAdapter(" select *  from CAN_PERSONALINFO where REFERANCE_ID=" + TextBox1.Text + " ", objcon);
  24.         DataSet objds = new DataSet();
  25.         OracleDataAdapter objda1 = new OracleDataAdapter(objcmd);
  26.         objda.Fill(objds);
  27.         GridView1.DataSource = objds.Tables[0];
  28.         GridView1.DataBind();
  29.         objcon.Close();
  30.  
  31.     }
  32.     protected void Button2_Click(object sender, EventArgs e)
  33.     {
  34.         try
  35.         {
  36.             OracleDataAdapter objcmd1 = new OracleDataAdapter("update  CAN_PERSONALINFO  SET FIRST_NAME=" + TextBox2.Text + " where REFERANCE_ID =" + TextBox1.Text + " ", objcon);
  37.             objcon.Open();
  38.             OracleDataAdapter objcmd2 = new OracleDataAdapter("select * from CAN_PERSONALINFO where REFERANCE_ID=" + TextBox1.Text + " ", objcon);
  39.             objcmd.ExecuteNonQuery();
  40.             DataSet ds2 = new DataSet();
  41.             OracleDataAdapter objda2 = new OracleDataAdapter(objcmd2);
  42.             objda2.Fill(ds2);
  43.             GridView1.DataSource = ds2.Tables[0];
  44.             GridView1.DataBind();
  45.             objcon.Close();
  46.             Label1.Text = "update your FIRST_NAME";
  47.  
  48.         }
  49.  
  50.         catch (Exception ex)
  51.         {
  52.             throw ex;
  53.         }
  54.     }
  55. }
Aug 20 '08 #1
3 5962
DrBunchman
979 Expert 512MB
Hi sumalatha055,

Welcome to Bytes.com! I hope you find the site useful but I need to mention a couple of things:

You've posted your question in the ASP Forum which is for Classic ASP only - I've moved it for you but in future please post all ASP.NET questions in the .NET Forum.

Please don't forget to wrap your code in CODE tags - it makes your posts much easier to read.

Your question does not contain enough detail - what do you mean by not responding? Are you getting an error?

Please read the Posting Guidelines if you have not done so already.

Good luck finding a solution,

Dr B
Aug 20 '08 #2
Curtis Rutland
3,256 Expert 2GB
You have several problems. You keep declaring new DataAdapters, but you are using (and trying to use) the first one. You need a better understanding of what's going on.

What I usually do is declare a connection, command, and adapter as global. Then I initialize them in my constructor/page_load method. But keep using the same one.

Also, you don't need to open and close your connections when you use a DataAdapter. It does that for you.

EDIT:
Spotted another problem.

You delcare a DataAdapter with an update command, which is already a problem, because you can't do that. You have to declare them with a select statement. But then you never use it.

You need to seriously rework your logic. Read this article I wrote. Hopefully you will have a better understanding about using DataAdapters and commands.
Aug 20 '08 #3
Dear sumalatha055

You have not used refrence file of Oracle provider.
You must use :

Using Oracle.DataAccess;
This will support for OracleDataAdapter and oracle connection.

Regards
Dec 18 '12 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: susmita_ganguly | last post by:
Hi I am trying to upgrade from oracle 8i to oracle 9i on the same server ..I don't know much abt migration . Can anyone help me out. Thanks. Susmita
38
by: Mike | last post by:
No flame wars, please! We're planning a move from a non-relational system to a relational system. Our choices have been narrowed to Oracle and DB2. Since we're moving from non-relational to...
11
by: Rosco | last post by:
Does anyone have a good URL or info whre Oracle and Access are compared to one another in performance, security, cost etc. Before you jump on me I know Oracle is a Cadillac compared to Access the...
2
by: phil03 | last post by:
Hi, I'm looking for some thoughts/guidance about the following scenario. A bit background first.... I have an Access database (BE) which has numerous linked tables connected to our company...
33
by: bill | last post by:
In an application I am writing the user can define a series of steps to be followed. I save them in a sql database using the field "order" (a smallint) as the primary key. (there are in the range...
2
by: ahogan | last post by:
Previously posted on comp.databases.oracle.misc. Apologies to those who read both groups. I have created a link using generic connectivity from an Oracle 10.2.0.1 instance running on windows...
2
by: Vinod Sadanandan | last post by:
All, Below listed are the new features in Oracle 11g ,please join me in this discussion to generate a testcase and analyze each of the listed features . Precompilers:...
1
by: cpeters | last post by:
Can anyone see what's wrong with this update statement? It works on my DB2 database, but not on my Oracle 9i database. Any help would be much appreciated. Thx, Coleen I want to set...
0
by: Jack | last post by:
Training Classes for Oracle10g, 9i, 8i Certification training in Oracle10g and 9i: DBA, Developer, Discoverer. training conducted at your location worldwide. Courseware licensing also available....
0
by: Winder | last post by:
Training Classes for Oracle10g, 9i, 8i Certification training in Oracle10g and 9i: DBA, Developer, Discoverer. training conducted at your location worldwide. Courseware licensing also available....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.