473,386 Members | 1,786 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,386 software developers and data experts.

C++/CLI OleDbException Error

255 100+
Hi guys,

I'm having a System.Data.OleDb.OleDbException error with C++/CLI language environment. I've created a form with a DataGridView to show the whole table from the database, it is allowed to modify the records from the DataGridView. Once a button is pressed it will start the code below
Expand|Select|Wrap|Line Numbers
  1. conn->Open();
  2.  
  3. //Get changed rows if existed
  4. dsChange = dsFac->GetChanges(DataRowState::Modified);
  5. dsAdd = dsFac->GetChanges(DataRowState::Added);
  6. dsDelete = dsFac->GetChanges(DataRowState::Deleted);
  7.  
  8. da = daFac;
  9. strTable = "Facility";
  10.  
  11. if(dsChange)
  12. {
  13.     strSQL = "UPDATE Facility "
  14.              "SET FName = @FName, FDescription = @FDescription "
  15.              "WHERE FID = @FID";
  16.     cmd = gcnew OleDbCommand(strSQL,conn);
  17.     cmd->Parameters->Add("@FID", OleDbType::Char, 5, "FID");
  18.     cmd->Parameters->Add("@FName", OleDbType::VarChar, 15, "FName");
  19.     cmd->Parameters->Add("@FDescription", OleDbType::VarChar, 40, "FDescription");
  20.     da->UpdateCommand = cmd;
  21.     da->Update(dsChange, strTable);
  22. }
  23. if(dsAdd)
  24. {
  25.     strSQL = "INSERT INTO Facility (FID, FName, FDescription) "
  26.              "VALUES (@FID, @FName, @FDescription)";
  27.     cmd = gcnew OleDbCommand(strSQL,conn);
  28.     cmd->Parameters->Add("@FID", OleDbType::Char, 5, "FID");
  29.     cmd->Parameters->Add("@FName", OleDbType::VarChar, 15, "FName");
  30.     cmd->Parameters->Add("@FDescription", OleDbType::VarChar, 40, "FDescription");
  31.     da->InsertCommand = cmd;
  32.     da->Update(dsAdd, strTable);
  33. }
  34. if(dsDelete)
  35. {
  36.     strSQL = "DELETE FROM Facility WHERE FID = @FID";
  37.     cmd = gcnew OleDbCommand(strSQL,conn);
  38.     cmd->Parameters->Add("@FID", OleDbType::Char, 5, "FID");
  39.     da->DeleteCommand = cmd;
  40.     da->Update(dsDelete, strTable);
  41. }
The code above will detect the Modified, Added, Deleted actions made from the user. For example I'm updating one of the FDescription field in the records, pressed the button and it shows an error pointing to this line.
Expand|Select|Wrap|Line Numbers
  1. da->Update(dsChange, strTable);
Where the error message is:
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in System.Data.dll

Additional information: No value given for one or more required parameter


This is the stack captured for the error..
Expand|Select|Wrap|Line Numbers
  1.      System.Data.dll!System.Data.Common.DbDataAdapter.UpdatedRowStatusErrors(System.Data.Common.RowUpdatedEventArgs rowUpdatedEvent, System.Data.Common.DbDataAdapter.BatchCommandInfo[] batchCommands, int commandCount) + 0x18b bytes    
  2.      System.Data.dll!System.Data.Common.DbDataAdapter.UpdatedRowStatus(System.Data.Common.RowUpdatedEventArgs rowUpdatedEvent, System.Data.Common.DbDataAdapter.BatchCommandInfo[] batchCommands, int commandCount) + 0x2e bytes    
  3.      System.Data.dll!System.Data.Common.DbDataAdapter.Update(System.Data.DataRow[] dataRows, System.Data.Common.DataTableMapping tableMapping) + 0x7d2 bytes    
  4.      System.Data.dll!System.Data.Common.DbDataAdapter.UpdateFromDataTable(System.Data.DataTable dataTable, System.Data.Common.DataTableMapping tableMapping) + 0x2a bytes    
  5.      System.Data.dll!System.Data.Common.DbDataAdapter.Update(System.Data.DataSet dataSet, string srcTable) + 0xb1 bytes    
  6. >    WWZ_Admin.exe!WWZ_Admin::WWZ_DB::btnUpdate_Click(System::Object^ sender, System::EventArgs^ e) Line 372 + 0x11 bytes    C++
  7.  
Can anyone tell me what am I missing on the dataset settings? or is it an error in another part? Any help is greatly appreciated.
Oct 3 '10 #1
0 1228

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

Similar topics

3
by: G.Esmeijer | last post by:
Friends, The following code works fin. BUT... after a >> couple times<< this code is used is a class it comes with an error saying unhandled System.Data.OleDb.OleDbException' occurred in...
0
by: Alex | last post by:
Hi, is it possible to determine exactly what type of error/exception was thrown from a try catch block bt simple catching the generic error. by this I mean, suppose I have the follwoing code...
1
by: T8 | last post by:
I have a asp.net (framework 1.1) site interfacing against SQL 2000. It runs like a charm 99% of the time but once in a while I get the following "unspecified error". Sometimes it would resolve by...
3
by: GotdotNet | last post by:
I get this error once in a while and I normally could fix it by restarting IIS. However, I would like to find out what causes this. Can anyone help? -----------------------------error...
7
by: Jim McGivney | last post by:
ASPX page from VS.net-C# on host's computer using oleDataAdaptor to connect to Microsoft Access database. The page loads, but when connection to the database is attempted to fill a datagrid the...
5
by: petro | last post by:
Hello all, My asp.net web application works on my machine but I get the following error on our test web server, There is only one oracle home on the test server. Does anyone know how to resolve...
0
by: Darrell | last post by:
Hello, I have the following SQL statement in an OleDbDataAdapter: SELECT Customers.Watch, Format(FinStmts., 'MM/DD/YY') AS ExpDate, Customers.FullName, Customers.Phone1, Customers.SSN, ...
0
by: mkahn | last post by:
Fater leaving my computer for a few minutes. I tried to continue working with the page am on. Seems to be that after my connection timed out, am not able to reconnect to the data base getting the...
0
by: vatrix | last post by:
I get an error meessage and a crash on my OleDbDataAdapter from the following code trying to call up record meeting a simple date criteria. What am I doing wrong. Been on this problem for a week now....
0
by: rn5a | last post by:
When a user finally confirms his order in a shopping cart application (using MS-Access as the backend), the items he has purchased are populated in a Access DB table named *Orders* & his personal...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...

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.