473,806 Members | 2,582 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Exception error when importing datagridview to Oracle

8 New Member
Hi, I'm trying to update a datagrid view table to the Oracle DB.
This is my code so far....


Expand|Select|Wrap|Line Numbers
  1. // Connection to Oracle DB   
  2.  int connectionCounter = 0;   
  3.                 bool boolUpdateData = true;   
  4.                 while (boolUpdateData && connectionCounter < 3)   
  5.                 {   
  6.                     try   
  7.                     {   
  8.                         localConnection = new OracleConnection(localFunction.localConnectionString);   
  9.                         localConnection.Open();   
  10.  
  11.                         boolUpdateData = false;   
  12.                     }   
  13.                     catch (Exception localException)   
  14.                     {   
  15.                         localFunction.WriteEventLog(localException.ToString(), "OPCAlarmConfig");   
  16.                     }   
  17.                     connectionCounter++;   
  18.                 }   
  19.  
  20.                 localSQL = @"SELECT * FROM SYS_LINE";   
  21.                 localFunction.ExecuteOracleNonQuery(localSQL, localConnection, "OPCAlarmConfig");   
  22.  
  23. // Update Oracle DB   
  24.          try {   
  25.             OracleCommandBuilder cb = new OracleCommandBuilder(oleda);   
  26.             userTable = ds.Tables["SYS_LINE"];   
  27.             oleda.Fill(ds,"SYS_LINE");   
  28.             excelGridView.DataSource = ds.Tables[0];   
  29.             oleda.Update(ds, "SYS_LINE");   
  30.               }   
  31.                 catch (Exception imptoracle)   
  32.                 { MessageBox.Show(imptoracle.ToString()); }   
  33.             }   
  34.  

This exception error "Object reference not set to an instance of an object" kept appearing on the "oleda.Fill(ds, "SYS_LINE") ;" line

Can anyone help?
Feb 18 '09 #1
2 2000
Curtis Rutland
3,256 Recognized Expert Specialist
Well, you haven't shown us in this code where you instantiate your DataAdapter object (oleda). Without that, I can't tell exactly whats wrong.

It looks like you either never instantiated it, or you never set it's select command, based on the error.
Feb 18 '09 #2
csharp learner
8 New Member
This is where my form loads.
Expand|Select|Wrap|Line Numbers
  1. public void displayexcel_Load(object sender, EventArgs e)
  2.         {
  3.             try
  4.             {
  5.                 string connString = "provider=Microsoft.Jet.OLEDB.4.0;data source=" + gotdirectory + @";Extended Properties=""Excel 8.0;HDR=YES;""";
  6.                 OleDbConnection oledbConn = new OleDbConnection(connString);
  7.                 oledbConn.Open();
  8.                 OleDbCommand cmd = new OleDbCommand("SELECT * FROM [A2:O36]", oledbConn);
  9.                 OleDbDataAdapter oleda = new OleDbDataAdapter();
  10.                 oleda.SelectCommand = cmd;
  11.                 oleda.Fill(ds);
  12.                 userTable = ds.Tables[0];
  13.                 excelGridView.DataSource = ds.Tables[0].DefaultView;
  14.                 excelGridView.ReadOnly = true;
  15.                 oledbConn.Close();
  16.             }
  17.             catch (Exception displayerror)
  18.             {
  19.                 MessageBox.Show(displayerror.ToString());
  20.             }
  21.         }
  22.  
Feb 19 '09 #3

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

Similar topics

3
7301
by: Paul Miller | last post by:
Is there any particular good reason to inherit from exceptions.Exception? I've never seen any code that depends on what the base class(es) of a raised exception is (are). My use case is in a game I am writing. The code for my Game class contains the following: class Game (object): def start (self):
3
2514
by: JohnDeHope3 | last post by:
First let me say that I understand that Asp.Net wraps my exception in an HttpUnhandledException. I have found a lot of discussion about that on the web, which was informative, but not helpful. Let me explain how my question is different. Second, let me say that I have two questions. One is an ASP.Net related question. The other is a general System.Exception question. They are related but also individual. Okay here is my problem...
3
1449
by: PJ6 | last post by:
If I have a DataGridView in my form, when I click on the DataSource property, I get a message box displaying the exception message, "Object reference not set to instance of an object." What's even more amusing is if I try to set the property using the little box that pops up immediately after I add a DataGridView to my form, the IDE crashes. Uh... is there a fix for this?
1
3126
by: guzmanp | last post by:
I have this error message: Please anyone knows how I resolve this? An unexpected exception has been detected in native code outside the VM. Unexpected Signal : EXCEPTION_ACCESS_VIOLATION occurred at PC=0x1cd82c7d Function name=(N/A) Library=C:\Documents and Settings\administrator.INDSFT\Local Settings\Temp\OraInstall2006-11-03_01-36-14PM\SID_Queries.dll NOTE: We are unable to locate the function name symbol for the error just...
0
2507
by: jeastman - Hotmail | last post by:
Hello world Excuse, not to be written English and it helps me with a translator. I am new programming in C#. I made a control inheriting the DataGridView to be able to add controls done by my.
4
2146
by: vasavimaruthi | last post by:
hi, i got class not found exception of a small jdbc program in windows. the program is like this import java.sql.*; public class Db1 { public static void main(String a) throws Exception { Class.forName("oracle.jdbc.driver.OracleDriver");
2
2529
by: erbrose | last post by:
Hey friends i just wrote some code that finds a zip file in a folder, unzips it using system() call to winzip32.exe. the contents of zip is an oracle dmp file. I next use another system() call to oracles imp command to import the dmp file to a schema in oracle. It works just fine. What I need to do now is copy the contents of the shell window output to a text file so that i can look later to see if it worked correctly.. use warnings; use...
3
6949
by: sriram347 | last post by:
Hi I am a newbie to ASP.NET. I developed a web page (project type is web application) and I keep getting this error. B]Error message : "System.AccessViolation Exception attempted to read or write protected memory. this is often an indication that other memory is corrupt.... " These are all the platform info : Visual Studio 2005 (VB.NET) and ASP.NET 2.0.
4
4885
by: alex21 | last post by:
Ok im getting this exception from a DataGridView control in my program. System.ArgumentOutOfRangeException was unhandled Message="Value of '132' is not valid for 'Value'. 'Value' should be between 'minimum' and 'maximum'.\r\nParameter name: Value" Source="System.Windows.Forms" ParamName="Value" StackTrace: at System.Windows.Forms.ScrollBar.set_Value(Int32 value) at System.Windows.Forms.DataGridView.ScrollRows(Int32...
0
10620
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10369
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10110
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9187
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7650
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4329
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.