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

problem with the update

18
private void btnSave_Click(object sender, EventArgs e)
{
//this.dataGridView1.CurrentRow.Cells[5].Value.ToString())
string sqlCommand;
sqlCommand =
"Update Inventory SET @ItemDescription= ? " + ",@ItemNumber= ?" +
",@ItemCode= ? " + ",@ItemType= ?" + ",@Location= ? " +
",@DateItemCreated= ? " +
",@Unit= ? " +
",@OurPrice= ? " + ",@StudentPrice= ? " + ",@PONumber= ? " +
",@Quantity= ? " + " Where ItemNumber= ? ";
myOleDbCommand = new OleDbCommand(sqlCommand, myOleDbConnection);


myOleDbCommand.Parameters.Add("ItemDescription", this.dataGridView1.CurrentRow.Cells[0].Value.ToString());
myOleDbCommand.Parameters.Add("ItemNumber",Int32.P arse( this.dataGridView1.CurrentRow.Cells[1].Value.ToString()));
myOleDbCommand.Parameters.Add("ItemCode", this.dataGridView1.CurrentRow.Cells[2].Value.ToString());
myOleDbCommand.Parameters.Add("ItemType", this.dataGridView1.CurrentRow.Cells[3].Value.ToString());
myOleDbCommand.Parameters.Add("Location", this.dataGridView1.CurrentRow.Cells[4].Value.ToString());
myOleDbCommand.Parameters.Add("DateItemCreated", this.dataGridView1.CurrentRow.Cells[5].Value.ToString());
myOleDbCommand.Parameters.Add("Unit", this.dataGridView1.CurrentRow.Cells[6].Value.ToString());
myOleDbCommand.Parameters.Add("OurPrice", this.dataGridView1.CurrentRow.Cells[7].Value.ToString());
myOleDbCommand.Parameters.Add("StudentPrice", this.dataGridView1.CurrentRow.Cells[8].Value.ToString());
myOleDbCommand.Parameters.Add("PONumber", this.dataGridView1.CurrentRow.Cells[9].Value.ToString());
myOleDbCommand.Parameters.Add("Quantity", this.dataGridView1.CurrentRow.Cells[10].Value.ToString());


myOleDbCommand.ExecuteNonQuery();
this.myDataSet.AcceptChanges();
myOleDbDataAdapter.Update(myDataSet, "Inventory");


}//end Save

I am having a problem, when I am trying to update my access database with the help of "datagriedview" in C#. It gives me an error at runtime i.e OleDbException was unhandled "No value given for one or more required parameters."

Could any one tell me what I am doing wrong?
Also the 5th column in my database is date/time type in my access database, but I am only interested in date portion.
Feb 4 '07 #1
1 1144
kenobewan
4,871 Expert 4TB
Looks like it is looking for the where item number...Format date to d...

Hope that this helps.
Feb 5 '07 #2

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

Similar topics

7
by: Zachary Hilbun | last post by:
The below is some test code to help me learn how to update a dataset. It is supposed to read the value of UserCounter and write it back. The UserCounter is being read correctly as 0, is 1 when...
5
by: junglist | last post by:
Hi guys, I've been trying to implement an editable datagrid and i have been succesful up to the point where i can update my datagrid row by row. However what used to happen was that once i updated...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
3
by: Juan Antonio Villa | last post by:
Hello, I'm having a problem replicating a simple database using the binary log replication, here is the problem: When the master sends an update to the slave, an example update reads as follows:...
11
by: SAL | last post by:
Hello, I have a Gridview control (.net 2.0) that I'm having trouble getting the Update button to fire any kind of event or preforming the update. The datatable is based on a join so I don't know...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.