Click here to Skip to main content
15,909,827 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C++
int val = 0;
                OleDbCommand cmdUpdateCommand = new OleDbCommand("Update LineDetails set Shift=?, LineNumber=?, Active=?, NoPlan=?, OOS=?, Cleaning=?, NoMan=?, OOSDetails=?, [Date]=? where Shift=?", conn);

                cmdUpdateCommand.Parameters.Add("Shift", OleDbType.Char).Value = dgvLineDetails.CurrentRow.Cells["Shift"].Value;
                cmdUpdateCommand.Parameters.Add("LineNumber", OleDbType.Integer).Value = dgvLineDetails.CurrentRow.Cells["LineNumber"].Value;
                cmdUpdateCommand.Parameters.Add("Active", OleDbType.Boolean).Value = dgvLineDetails.CurrentRow.Cells["Active"].Value;
                cmdUpdateCommand.Parameters.Add("NoPlan", OleDbType.Boolean).Value = dgvLineDetails.CurrentRow.Cells["NoPlan"].Value;
                cmdUpdateCommand.Parameters.Add("OOS", OleDbType.Boolean).Value = dgvLineDetails.CurrentRow.Cells["OOS"].Value;
                cmdUpdateCommand.Parameters.Add("Cleaning", OleDbType.Boolean).Value = dgvLineDetails.CurrentRow.Cells["Cleaning"].Value;
                cmdUpdateCommand.Parameters.Add("NoMan", OleDbType.Boolean).Value = dgvLineDetails.CurrentRow.Cells["NoMan"].Value;
                cmdUpdateCommand.Parameters.Add("OOSDetails", OleDbType.Char).Value = dgvLineDetails.CurrentRow.Cells["OOSDetails"].Value;
                cmdUpdateCommand.Parameters.Add("Date", OleDbType.Date).Value = dgvLineDetails.CurrentRow.Cells["Date"].Value;

                conn.Open();
                val = cmdUpdateCommand.ExecuteNonQuery();
                if (val > 0)
                {
                    MessageBox.Show("Shift Updated");
                }
                conn.Close();


when i m updating using above code Its gives exception No value given for one or more paramaeter. Anyone can help me how to solve it. Urgent.. Today is my project deadline.... Thanks a lot
Posted

Today is my project deadline
who gives a shite! you think anyone will loose a sleep? That is your problem.

Hint: Check your parameter list i.e "?" and the number of values passed. Think the last one, huh?

Between this and the error message you got, there is plenty of clue for you to figure it out on your own, huh :doh:
 
Share this answer
 
Since you are using '?' as the parametrized query, you need to give all the parameters, even though if it is repeated. Thus one parameter value supply is missing.

If you use Shift = @Shift and so...in query.
and then
cmdUpdateCommand.Parameters.Add("@Shift", OleDbType.Char)...

this should work for you as Shift is the parameter that will be used twice and supplying value once would be enough.
For sample example, look here:
Using Parameterized Queries in ASP.Net[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900