error 0x80040E10 in update in c# with access database

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

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

#1 rizsoomro   User is offline

  • D.I.C Head

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

error 0x80040E10 in update in c# with access database

Posted 11 December 2018 - 05:51 AM

I create a project in c# with access database i want to retrieve database to textboxes when I enter the FormCode in txtFormCode.text but this error is appear i check database carefully and code;

private void txtFormCode_KeyDown(object sender, KeyEventArgs e)
		{
			try
			{
				if (e.KeyCode == Keys.Enter)
				{

					string InsertPur = "Select * from Payment where FormCode=" + txtFormCode.Text + " and [Status]= '" + "Active" + "' and ProjectName='" + lblProName.Text + "' ";
					OleDbDataAdapter da = new OleDbDataAdapter(InsertPur,conn);
					DataSet ds = new DataSet();
					da.Fill(ds); //error stop here

					txtCOName.Text = ds.Tables[0].Rows[0]["NameApplicant"].ToString();
					txtCOFName.Text = ds.Tables[0].Rows[0]["FatherName"].ToString();
					txtCOCNIC.Text = ds.Tables[0].Rows[0]["CNICNo"].ToString();
					txtCOAddres.Text = ds.Tables[0].Rows[0]["ApplicantAddress"].ToString();
					txtCOMobile.Text = ds.Tables[0].Rows[0]["MobileNo"].ToString();
					txtCOResTel.Text = ds.Tables[0].Rows[0]["ResidenceTel"].ToString();

					txtPlotNo.Text = ds.Tables[0].Rows[0]["PlotBanglowNo"].ToString();
					txtCategory.Text = ds.Tables[0].Rows[0]["Category"].ToString();
					txtPlotType.Text = ds.Tables[0].Rows[0]["Type"].ToString();
					txtPlotBlock.Text = ds.Tables[0].Rows[0]["Block"].ToString();
					txtPlotSize.Text = ds.Tables[0].Rows[0]["PlotSize"].ToString();
					txtTAmount.Text = ds.Tables[0].Rows[0]["TotalAmount"].ToString();
					txtRemAmount.Text = ds.Tables[0].Rows[0]["RemainingAmount"].ToString();

					txtFormCode.Focus();
				}
			}
			catch (Exception ex)
			{
				MetroFramework.MetroMessageBox.Show(this, "Error" + ex, "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
			}
		}


This post has been edited by rizsoomro: 11 December 2018 - 05:52 AM


Is This A Good Question/Topic? 0
  • +

Replies To: error 0x80040E10 in update in c# with access database

#2 andrewsw   User is offline

  • quantum multiprover
  • member icon

Reputation: 6777
  • View blog
  • Posts: 27,959
  • Joined: 12-December 12

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

Posted 11 December 2018 - 06:14 AM

What do you consider that the error might mean?

Is FormCode a textual value?
Was This Post Helpful? 0
  • +
  • -

#3 modi123_1   User is online

  • Suitor #2
  • member icon



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

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

Posted 11 December 2018 - 06:20 AM

Start by using parameters.
Was This Post Helpful? 1
  • +
  • -

#4 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 11 December 2018 - 06:51 AM

andrewsw no this is numeric
Was This Post Helpful? 0
  • +
  • -

#5 TechnoBear   User is offline

  • Lady A
  • member icon

Reputation: 345
  • View blog
  • Posts: 1,249
  • Joined: 02-November 11

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

Posted 11 December 2018 - 06:55 AM

Have you made absolutely any of the recommended changes from the last, god knows how many, posts on this?

What is the error? What line is triggering it?
Was This Post Helpful? 0
  • +
  • -

#6 Sheepings   User is offline

  • Senior Programmer
  • member icon

Reputation: 210
  • View blog
  • Posts: 1,190
  • Joined: 05-December 13

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

Posted 11 December 2018 - 06:58 AM

The error means a different type of value was expected other than what was provided.
Was This Post Helpful? 0
  • +
  • -

#7 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 11 December 2018 - 08:47 AM

i think this error comes that,i have duplicate values i.e in payment entries are multiple and FormCode is repeated in multiple dates now i have this issue that how to retrieve that Form if it have more than one entries??? I want to retrieve last updated entry. please anyone guide me about this issue..
Was This Post Helpful? 0
  • +
  • -

#8 modi123_1   User is online

  • Suitor #2
  • member icon



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

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

Posted 11 December 2018 - 08:48 AM

Quote

please anyone guide me about this issue..



1. Please post the exception.message text.

2. Use parameters.

08
                    string InsertPur = "Select * from Payment where FormCode=" + txtFormCode.Text + " and [Status]= '" + "Active" + "' and ProjectName='" + lblProName.Text + "' ";

Was This Post Helpful? 0
  • +
  • -

#9 Sheepings   User is offline

  • Senior Programmer
  • member icon

Reputation: 210
  • View blog
  • Posts: 1,190
  • Joined: 05-December 13

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

Posted 11 December 2018 - 09:04 AM

View Postrizsoomro, on 11 December 2018 - 03:47 PM, said:

i think this error comes that,i have duplicate values i.e

Which part of this did you not read ::

View PostSheepings, on 11 December 2018 - 01:58 PM, said:

The error means a different type of value was expected other than what was provided.

View Postmodi123_1, on 11 December 2018 - 03:48 PM, said:

1. Please post the exception.message text.
2. Use parameters.

This OP has been advised to use parameters a number of times but that advice falls on deaf ears.

I suggest OP picks up a book on the subject, instead of this trial'n'error shotgun approach. There was a number of things recommended in previous topics (One of many) which still hasn't changed in this code.
Was This Post Helpful? 0
  • +
  • -

#10 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 6840
  • View blog
  • Posts: 23,218
  • Joined: 05-May 12

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

Posted 11 December 2018 - 09:14 AM

I highly recommend using parameters. If you don't set parameters, at least set a breakpoint on line 10 and tell us what the value of InsertPur is so we have an idea of what the query looks like.
Was This Post Helpful? 0
  • +
  • -

#11 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 11 December 2018 - 12:27 PM

I use kind of parameters is this correct sir

private void txtFormCode_KeyDown(object sender, KeyEventArgs e)
		{
			try
			{
				if (e.KeyCode == Keys.Enter)
				{
                    conn.Open();
					OleDbCommand cmd = new OleDbCommand("Select * from Payment where FormCode="+txtFormCode.Text+" and [Status]='"+"Active"+"' and ProjectName='"+lblProName.Text+"' ", conn);
					OleDbDataReader reader = cmd.ExecuteReader();

					//cmd.Parameters.AddWithValue("@FormCode", txtFormCode.Text); //also tried this but nothing change
					//cmd.Parameters.AddWithValue("@Status", "Active");
					//cmd.Parameters.AddWithValue("@ProjectName", lblProName.Text);

					txtCOName.Text =reader["NameApplicant"].ToString();
					txtCOFName.Text = reader["FatherName"].ToString();
					txtCOCNIC.Text = reader["CNICNo"].ToString();
					txtCOAddres.Text = reader["ApplicantAddress"].ToString();
					txtCOMobile.Text = reader["MobileNo"].ToString();
					txtCOResTel.Text = reader["ResidenceTel"].ToString();
					txtPlotNo.Text = reader["PlotBanglowNo"].ToString();
					txtCategory.Text = reader["Category"].ToString();
					txtPlotType.Text = reader["Type"].ToString();
					txtPlotBlock.Text = reader["Block"].ToString();
					txtPlotSize.Text = reader["PlotSize"].ToString();
					txtTAmount.Text = reader["TotalAmount"].ToString();
					txtRemAmount.Text = reader["RemainingAmount"].ToString();

					txtFormCode.Focus();
                    conn.Close();
				}
			}
			catch (Exception ex)
			{
				MetroFramework.MetroMessageBox.Show(this, "Error" + ex, "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
			}
		}




This is complete Error;
ErrorSystem.Data.OleDb.OleDbException (0x80040E07): Data type mismatch in criteria expression. at Systerm.Data.OleDb.OleeDbCommand.ExcecuteCommandTextErroHandling(OleDbHResult hr) at Systerm.Data.OleDb.OleDbCommand.ExecuteCommanTextForSingleResult(tagDBPARAMSdbPramas, Object executeResult)
atSystem.Data.OleDbCommand.ExecuteCommandText(Object executeResult)
at Systerm.Data.OleDbCommand.ExecuteCommand(Commandbehavior behavior, Object)

Was This Post Helpful? 0
  • +
  • -

#12 modi123_1   User is online

  • Suitor #2
  • member icon



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

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

Posted 11 December 2018 - 12:35 PM

Where do you think you are using parameters? I am not seeing them.

https://docs.microso...framework-4.7.2
Was This Post Helpful? 0
  • +
  • -

#13 TechnoBear   User is offline

  • Lady A
  • member icon

Reputation: 345
  • View blog
  • Posts: 1,249
  • Joined: 02-November 11

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

Posted 11 December 2018 - 01:00 PM

You need to debug and see what your actual query is before proceeding. One of the values you are giving in your query is not the correct type. I suspect the fault is in:
FormCode="+txtFormCode.Text+"

but you're gonna want to debug and see what your actual query is before you try to send it.
Was This Post Helpful? 0
  • +
  • -

#14 Sheepings   User is offline

  • Senior Programmer
  • member icon

Reputation: 210
  • View blog
  • Posts: 1,190
  • Joined: 05-December 13

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

Posted 11 December 2018 - 02:05 PM

View Postrizsoomro, on 11 December 2018 - 12:51 PM, said:

string InsertPur = "Select * from Payment where FormCode=" + txtFormCode.Text + " and [Status]= '" + "Active" + "' and ProjectName='" + lblProName.Text + "' ";


Read the link Modi gave you and dump the dissecting approach "" + "" + "" + "" and write your query string as one WHOLE string using [email protected] Then when you uncomment your code ::
cmd.Parameters.AddWithValue("@FormCode", txtFormCode.Text); //also tried this but nothing change

You will be using parameters upon executing your command.

BUT, nothing will change in terms of fixing your current error after applying parameters, because you are feeding a value of the wrong type. (But, using parameters puts you on the right track.) Think about what I said above; here is a clue

A string is a type, int is a different type, double, decimal, all other types different to strings. Hence the compile error ::
Data type mismatch in criteria expression

Provide the value of your textboxes/labels in your command at the time your statement executes. What are they?
Also post back your code with the parameters applied. And we can go from there....
Was This Post Helpful? 0
  • +
  • -

#15 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 12 December 2018 - 05:07 AM

this code done nothing just back to txtFormCode;
I use 1st time parameters in Select query kindly check it;

private void txtFormCode_KeyDown(object sender, KeyEventArgs e)
		{

			try
			{
				conn.Open();
				OleDbCommand cmd = new OleDbCommand("Select * from Payment where [email protected] and [email protected] and [email protected] ", conn);
				cmd.Parameters.AddWithValue("@FormCode", txtFormCode.Text);
				cmd.Parameters.AddWithValue("@ProjectName", lblProName.Text);
				cmd.Parameters.AddWithValue("@Status", "Active");

				cmd.Parameters.AddWithValue("@NameApplicant",txtCOName.Text);
				cmd.Parameters.AddWithValue("@FatherName",txtCOFName.Text);
				cmd.Parameters.AddWithValue("@CNICNo",txtCOCNIC.Text);
				cmd.Parameters.AddWithValue("@ApplicantAddress",txtCOAddres.Text);
				cmd.Parameters.AddWithValue("@MobileNo",txtCOMobile.Text);
				cmd.Parameters.AddWithValue("@ResidenceTel",txtCOResTel.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("@RemainingAmount",txtRemAmount.Text);

				cmd.ExecuteReader();
				conn.Close();
			}
			catch (Exception ex)
			{
				MetroFramework.MetroMessageBox.Show(this, "Error" + ex, "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
			}
		}


Was This Post Helpful? 0
  • +
  • -

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