error 0x80040E10 in update in c# with access database

  • (4 Pages)
  • +
  • 1
  • 2
  • 3
  • 4

50 Replies - 1444 Views - Last Post: 19 December 2018 - 09:34 AM Rate Topic: -----

#31 TechnoBear   User is offline

  • Lady A
  • member icon

Reputation: 341
  • View blog
  • Posts: 1,243
  • Joined: 02-November 11

Re: error 0x80040E10 in update in c# with access database

Posted 13 December 2018 - 07:40 AM

I am aware of that response, Sheepings, however txtForm.Text could still potentially contain "", "Hi", or any number of non-numeric values... The question everyone keeps asking is what exactly it contains? and not only that but is Status parameter string? and what is the Project name parameter?

There is an invalid cast happening in the query, so one of these inputs likely cannot be cast to the parameter type. Without that information we will not get far, some of us are very good at this job but none of us are mind readers.
Was This Post Helpful? 0
  • +
  • -

#32 rizsoomro   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 72
  • Joined: 26-January 18

Re: error 0x80040E10 in update in c# with access database

Posted 13 December 2018 - 10:45 AM

sorry to all of you i think i don't define my question clearly or i don't understand that what i'm trying but i'm trying to follow you but i'm beginner so i can't understand about language[wording] about coding which i understand that i try to reply you. anyway sorry again :(
Was This Post Helpful? 0
  • +
  • -

#33 TechnoBear   User is offline

  • Lady A
  • member icon

Reputation: 341
  • View blog
  • Posts: 1,243
  • Joined: 02-November 11

Re: error 0x80040E10 in update in c# with access database

Posted 13 December 2018 - 10:52 AM

View Postrizsoomro, on 13 December 2018 - 11:45 AM, said:

i'm beginner so i can't understand about language[wording] about coding which i understand that i try to reply you.


This is all well and good and we are all more than willing to support you as you make your steps moving forwards, but you just need to help us help you.
Was This Post Helpful? 0
  • +
  • -

#34 rizsoomro   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 72
  • Joined: 26-January 18

Re: error 0x80040E10 in update in c# with access database

Posted 13 December 2018 - 10:56 AM

ٖFormCode = string
ProjectName = string
Status = string
NameApplicant = string
FatherName = string
CNICNo = double
ApplicantAddress = string
MobileNo = double
ResidenceTel = double
PlotBanglowNo = int
Category = string
Type = string
Block = string
PlotSize = int

i think this is everyone asking!
Was This Post Helpful? 0
  • +
  • -

#35 TechnoBear   User is offline

  • Lady A
  • member icon

Reputation: 341
  • View blog
  • Posts: 1,243
  • Joined: 02-November 11

Re: error 0x80040E10 in update in c# with access database

Posted 13 December 2018 - 11:03 AM

I thought FormCode was numeric...
Was This Post Helpful? 0
  • +
  • -

#36 rizsoomro   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 72
  • Joined: 26-January 18

Re: error 0x80040E10 in update in c# with access database

Posted 13 December 2018 - 11:04 AM

sorry yes it's number
Was This Post Helpful? 0
  • +
  • -

#37 TechnoBear   User is offline

  • Lady A
  • member icon

Reputation: 341
  • View blog
  • Posts: 1,243
  • Joined: 02-November 11

Re: error 0x80040E10 in update in c# with access database

Posted 13 December 2018 - 11:33 AM

Is it possible you are putting non-numeric data in FormCode text box?
Was This Post Helpful? 0
  • +
  • -

#38 rizsoomro   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 72
  • Joined: 26-January 18

Re: error 0x80040E10 in update in c# with access database

Posted 13 December 2018 - 11:45 AM

:rolleyes2:

you got my mistake and i correct it thanks but i use my old code not parameters but please may i ask that why use of parameters are better than normal coding?
Was This Post Helpful? 0
  • +
  • -

#39 TechnoBear   User is offline

  • Lady A
  • member icon

Reputation: 341
  • View blog
  • Posts: 1,243
  • Joined: 02-November 11

Re: error 0x80040E10 in update in c# with access database

Posted 13 December 2018 - 11:49 AM

Parameters protect against injection attacks and are cleaner, easier to read, and easier to maintain.

From a security and maintenance perspective they are just all round better to use.
Was This Post Helpful? 0
  • +
  • -

#40 rizsoomro   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 72
  • Joined: 26-January 18

Re: error 0x80040E10 in update in c# with access database

Posted 13 December 2018 - 11:53 AM

hmm send me some video tutorials or links where i learn about use of parameter with detail or you teach me if you don't mind

This post has been edited by rizsoomro: 13 December 2018 - 11:53 AM

Was This Post Helpful? 0
  • +
  • -

#41 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14929
  • View blog
  • Posts: 59,607
  • Joined: 12-June 08

Re: error 0x80040E10 in update in c# with access database

Posted 13 December 2018 - 12:11 PM

I am certain someone posted a link about parameters.

They also help with data type matching for SQL strings. You know.. to avoid having to put tick marks around things or convert strings to integers the long way.
Was This Post Helpful? 0
  • +
  • -

#42 Sheepings   User is offline

  • Senior Programmer
  • member icon

Reputation: 209
  • View blog
  • Posts: 1,187
  • Joined: 05-December 13

Re: error 0x80040E10 in update in c# with access database

Posted 13 December 2018 - 12:15 PM

View Postrizsoomro, on 13 December 2018 - 05:45 PM, said:

sorry to all of you i think i don't define my question clearly or i don't understand that what i'm trying but i'm trying to follow you but i'm beginner so i can't understand about language[wording] about coding which i understand that i try to reply you. anyway sorry again :(
That's perfectly fine, we all started somewhere. :) Nobody is ever done learning!

View Postrizsoomro, on 13 December 2018 - 05:56 PM, said:

ٖFormCode = string
Spoiler

i think this is everyone asking!

No, I don't want the types of what you have declared them as. I want the values of those types you listed, so that we can all determine for ourselves what your issue was/is, and so we can advise you on using the appropriate cast to and from your DB.

Also, please reinstate those parameters, because if you don't have them next time you post a new problem, you'll find I'll be one less offering to help you. I'm just not one for offering advice that gets ignored at a whim.

We are not a tutoring service. If you don't understand a specific aspect of what has been listed by one of the members in this 40 post topic, reference that section in a quote and ask a specific question. Don't take me up wrong, we are all willing to help you, but you need to be willing to learn at the same time. If you ask a strong question, you will likely get strong answers.
Was This Post Helpful? 0
  • +
  • -

#43 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 6833
  • View blog
  • Posts: 23,210
  • Joined: 05-May 12

Re: error 0x80040E10 in update in c# with access database

Posted 13 December 2018 - 03:15 PM

View Postrizsoomro, on 13 December 2018 - 01:53 PM, said:

hmm send me some video tutorials or links where i learn about use of parameter with detail or you teach me if you don't mind

To understand why you would use parameters, all you need is this:
Posted Image
Was This Post Helpful? 1
  • +
  • -

#44 rizsoomro   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 72
  • Joined: 26-January 18

Re: error 0x80040E10 in update in c# with access database

Posted 18 December 2018 - 11:31 PM

i have 0x80040E10 error in Update statement in c# using Access Database my codes are as under;

private void btnSavePrint_Click(object sender, EventArgs e)
        {
			double c = Convert.ToDouble(txtOTCNIC.Text);
			double m = Convert.ToDouble(txtOTMobile.Text);
			double t = Convert.ToDouble(txtOTResTel.Text);

			try
			{
				if (MetroMessageBox.Show(this, "Are you sure you want to change ownership of this File???", "MAARS Software", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
				{
					{
						
						{
							// make a copy Booking Table ROW
							conn.Open();
							OleDbCommand cmd = new OleDbCommand("Insert into [Booking] select * from [Booking] where FormCode=" + txtFormCode.Text + " ", conn);
							cmd.ExecuteNonQuery();
							conn.Close();
						}
						
						{
							//then update these coloumns in copied row
							//OleDbDataAdapter da = new OleDbDataAdapter("update Booking set EntryDate='"+datepicker.Value.Date.ToString()+"', NameApplicant='"+txtOTName.Text+"', FatherName='"+ txtOTFName.Text +"', Occupation='"+ txtOTOccu.Text + "', MonthlyIncome="+ txtOTMInc.Text +", CNICNo="+c+", ApplicantAge="+ txtOTAge.Text +", ApplicantAddress='"+ txtOTAddres.Text +"', MobileNo="+m+", ResidenceTel="+t+", EmailID='"+ txtOTEmail.Text +"', NoOfDependents="+ txtOTDepend.Text +", Nominee='"+ txtOTNominee.Text +"', TotalAmount="+ txtTAmount.Text +", TotalPaid="+ txtTPaid.Text +", PaymentTitle='"+ "Installment Payment" +"', Paid="+ txtPaid.Text +", PaidVia='"+ dboxPayType.Text +"', OnlineSNo="+ txtOnlineSlip.Text +", OnlineDate='"+ dpOnlineDate.Value.Date.ToString() +"', ChequeNo="+ txtChequeNo.Text.ToString() +", ChequeDate='"+ dpChequeDate.Value.Date.ToString() +"', RemainingAmount="+ txtOTRemAmount.Text +", ModifiedBy='"+ lblLoginID.Text +"', ModiUserType='"+ lblUserType.Text +"', ModifiedDate='"+ datepicker.Value.Date.ToString() +"', Status='"+ "Active" +"', Transferred='"+ "Transferred" +"' ", conn);
							//DataSet ds = new DataSet();
							//da.Fill(ds);

							conn.Open();
							
							OleDbDataAdapter da = new OleDbDataAdapter();
							string query = "Update Booking SET EntryDate=?, NameApplicant=?, FatherName=?, Occupation=?, MonthlyIncome=?, CNICNo=?, ApplicantAge=?, ApplicantAddress=?, MobileNo=?, ResidenceTel=?, EmailID=?, NoOfDependents=?, Nominee=?, ProjectName=?, PlotBanglowNo=?, Category=?, Type=?, Block=?, PlotSize=?, TotalAmount=?, TotalPaid=?, PaymentTitle=?, Paid=?, PaidVia=?, OnlineSNo=?, OnlineDate=?, ChequeNo=?, ChequeDate=?, RemainingAmount=?, ModifiedBy=?, ModiUserType=?, ModifiedDate=?, Status=?, Transferred=? where FormCode='"+txtFormCode.Text+"' ";
							var cmd = new OleDbCommand(query, conn);
							//cmd.Parameters.AddWithValue("FormCode", txtFormCode.Text);
							cmd.Parameters.AddWithValue("EntryDate", datepicker.Value.Date.ToString());
							cmd.Parameters.AddWithValue("NameApplicant", txtOTName.Text);
							cmd.Parameters.AddWithValue("FatherName", txtOTFName.Text);
							cmd.Parameters.AddWithValue("Occupation", txtOTOccu.Text);
							cmd.Parameters.AddWithValue("MonthlyIncome", txtOTMInc.Text);
							cmd.Parameters.AddWithValue("CNICNo", c);
							cmd.Parameters.AddWithValue("ApplicantAge", txtOTAge.Text);
							cmd.Parameters.AddWithValue("ApplicantAddress", txtOTAddres.Text);
							cmd.Parameters.AddWithValue("MobileNo", m);
							cmd.Parameters.AddWithValue("ResidenceTel", t);
							cmd.Parameters.AddWithValue("EmailID", txtOTEmail.Text);
							cmd.Parameters.AddWithValue("NoOfDependents", txtOTDepend.Text);
							cmd.Parameters.AddWithValue("Nominee", txtOTNominee.Text);

							cmd.Parameters.AddWithValue("TotalAmount", txtTAmount.Text);
							cmd.Parameters.AddWithValue("TotalPaid", txtTPaid.Text);

							cmd.Parameters.AddWithValue("PaymentTitle", "Installment Payment");
							cmd.Parameters.AddWithValue("Paid", txtPaid.Text);
							cmd.Parameters.AddWithValue("PaidVia", dboxPayType.Text);
							cmd.Parameters.AddWithValue("OnlineSNo", txtOnlineSlip.Text);
							cmd.Parameters.AddWithValue("OnlineDate", dpOnlineDate.Value.Date.ToString());
							cmd.Parameters.AddWithValue("ChequeNo", txtChequeNo.Text.ToString());
							cmd.Parameters.AddWithValue("ChequeDate", dpChequeDate.Value.Date.ToString());
							cmd.Parameters.AddWithValue("RemainingAmount", txtOTRemAmount.Text);
							cmd.Parameters.AddWithValue("ModifiedBy", lblLoginID.Text);
							cmd.Parameters.AddWithValue("ModiUserType", lblUserType.Text);
							cmd.Parameters.AddWithValue("ModifiedDate", datepicker.Value.Date.ToString());
							cmd.Parameters.AddWithValue("Status", "Active");
							cmd.Parameters.AddWithValue("Transferred", "Transferred");
							da.UpdateCommand = cmd;
							da.UpdateCommand.ExecuteNonQuery();
							
							conn.Close();
						}
					}
					{
						// Save data to Payment Table
						conn.Open();
						OleDbCommand cmd = new OleDbCommand("Insert into Payment (FormCode,EntryDate,NameApplicant,FatherName,CNICNo,ApplicantAddress,MobileNo,ResidenceTel,EmailID,ProjectName,PlotBanglowNo,[Category],[Type],[Block],PlotSize,TotalAmount,TotalPaid,RemainingAmount,PaymentTitle,[Paid],PaidVia,OnlineSNo,OnlineDate,ChequeNo,ChequeDate,ModifiedBy,ModiUserType,ModifiedDate,[Status],[Transferred]) values (@FormCode,@EntryDate,@NameApplicant,@FatherName,@CNICNo,@ApplicantAddress,@MobileNo,@ResidenceTel,@EmailID,@ProjectName,@PlotBanglowNo,@Category,@Type,@Block,@PlotSize,@TotalAmount,@TotalPaid,@RemainingAmount,@PaymentTitle,@Paid,@PaidVia,@OnlineSNo,@OnlineDate,@ChequeNo,@ChequeDate,@ModifiedBy,@ModiUserType,@ModifiedDate,@Status,@Transferred)", conn);
						cmd.Parameters.AddWithValue("@FormCode", txtFormCode.Text);
						cmd.Parameters.AddWithValue("@EntryDate", datepicker.Value.Date.ToString());
						cmd.Parameters.AddWithValue("@NameApplicant", txtOTName.Text);
						cmd.Parameters.AddWithValue("@FatherName", txtOTFName.Text);
						cmd.Parameters.AddWithValue("@CNICNo", c);
						cmd.Parameters.AddWithValue("@ApplicantAddress", txtOTAddres.Text);
						cmd.Parameters.AddWithValue("@MobileNo", m);
						cmd.Parameters.AddWithValue("@ResidenceTel", t);
						cmd.Parameters.AddWithValue("@EmailID", txtOTEmail.Text);
						cmd.Parameters.AddWithValue("@ProjectName", lblProName.Text);
						cmd.Parameters.AddWithValue("@PlotBanglowNo", txtPlotNo.Text);
						cmd.Parameters.AddWithValue("@Category", txtCategory.Text);
						cmd.Parameters.AddWithValue("@Type", txtPlotType.Text);
						cmd.Parameters.AddWithValue("@Block", txtPlotBlock.Text);
						cmd.Parameters.AddWithValue("@PlotSize", txtPlotSize.Text);
						cmd.Parameters.AddWithValue("@TotalAmount", txtTAmount.Text);
						cmd.Parameters.AddWithValue("@TotalPaid", txtTPaid.Text);
						cmd.Parameters.AddWithValue("@RemainingAmount", txtOTRemAmount.Text);
						cmd.Parameters.AddWithValue("@PaymentTitle", "Installment Payment");
						cmd.Parameters.AddWithValue("@Paid", txtPaid.Text);
						cmd.Parameters.AddWithValue("@PaidVia", dboxPayType.Text);
						cmd.Parameters.AddWithValue("@OnlineSNo", txtOnlineSlip.Text);
						cmd.Parameters.AddWithValue("@OnlineDate", dpOnlineDate.Value.Date.ToString());
						cmd.Parameters.AddWithValue("@ChequeNo", txtChequeNo.Text.ToString());
						cmd.Parameters.AddWithValue("@ChequeDate", dpChequeDate.Value.Date.ToString());
						cmd.Parameters.AddWithValue("@ModifiedBy", lblLoginID.Text);
						cmd.Parameters.AddWithValue("@ModiUserType", lblUserType.Text);
						cmd.Parameters.AddWithValue("@ModifiedDate", datepicker.Value.Date.ToString());
						cmd.Parameters.AddWithValue("@Status", "Active");
						cmd.Parameters.AddWithValue("@Transferred", "Transferred");
						cmd.ExecuteNonQuery();
						conn.Close();
					}
					ClearAll();
					MetroMessageBox.Show(this, "File Transferred successfully. Please wait for Print", "MAARS Software");
				}
			}
			catch (Exception ex)
			{
				MetroFramework.MetroMessageBox.Show(this, "Error" + ex, "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
			}
		}



1st and 3rd Insert statement works OK but 2nd Update statement show this error

Quote

and try to use parameter with suggestion of SkyDriver and thanks to all about previous conversation and specially SkyDriver who brief me about Parameter.

Attached image(s)

  • Attached Image

This post has been edited by rizsoomro: 18 December 2018 - 11:37 PM

Was This Post Helpful? 0
  • +
  • -

#45 MentalFloss   User is offline

  • .
  • member icon

Reputation: 619
  • View blog
  • Posts: 1,590
  • Joined: 02-September 09

Re: error 0x80040E10 in update in c# with access database

Posted 19 December 2018 - 12:32 AM

Put a breakpoint on line: var cmd = new OleDbCommand(query, conn); and then step through each instruction to find the field without a value.
Was This Post Helpful? 1
  • +
  • -

  • (4 Pages)
  • +
  • 1
  • 2
  • 3
  • 4