error 0x80040E10 in update in c# with access database

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

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

#16 andrewsw   User is offline

  • quantum multiprover
  • member icon

Reputation: 6778
  • View blog
  • Posts: 27,973
  • Joined: 12-December 12

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

Posted 12 December 2018 - 05:35 AM

By "done nothing" do you mean that you still get exactly the same error? Otherwise, what happens?
[Avoid expressions like "done nothing", they do not advance the topic nor encourage intercourse.]

Remove or comment out all those unused parameters, @NameApplicant, etc.

You also haven't responded to confirm what those values are.
Was This Post Helpful? 0
  • +
  • -

#17 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:39 AM

nothing happened NO ERROR just return back to txtFormCode.text i think something missing in my these code
Was This Post Helpful? 0
  • +
  • -

#18 Sheepings   User is offline

  • Senior Programmer
  • member icon

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

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

Posted 12 December 2018 - 05:42 AM

View Postrizsoomro, on 12 December 2018 - 12:07 PM, said:

this code done nothing just back to txtFormCode;
I use 1st time parameters in Select query kindly check it;
I told you this, and in fact, your changed code did do something, it protects you from injection attacks, and its the proper way to do it when working with database queries. I also told you this mismatch error would remain, and explained why. But we will fix it...

View PostSheepings, on 11 December 2018 - 09:05 PM, said:

BUT, nothing will change in terms of fixing your current error after applying parameters
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....

Second part now; what are the labels and textbox .text properties values when this statement runs?
Was This Post Helpful? 0
  • +
  • -

#19 andrewsw   User is offline

  • quantum multiprover
  • member icon

Reputation: 6778
  • View blog
  • Posts: 27,973
  • Joined: 12-December 12

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

Posted 12 December 2018 - 05:53 AM

All you do at the end of that code is call ExecuteReader so, no, nothing will appear to happen.
Was This Post Helpful? 1
  • +
  • -

#20 Sheepings   User is offline

  • Senior Programmer
  • member icon

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

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

Posted 12 December 2018 - 05:57 AM

You beat me to it Andrewsw.

@rizsoomro Where you getting the mismatch error when inserting into the DB?
Was This Post Helpful? 0
  • +
  • -

#21 Sheepings   User is offline

  • Senior Programmer
  • member icon

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

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

Posted 12 December 2018 - 06:08 AM

rizsoomro use a actual reader to read the results.
            using (OleDbCommand cmd = new OleDbCommand("Statement", Conn))
            {   
                cmd.Parameters.AddWithValue("@Parameter", "YourValuehere");
                using (OleDbDataReader QueryReader = cmd.ExecuteReader())
                {
                    while (QueryReader.Read())
                    {
                        var someString = QueryReader.GetString(0);
                    }
                }
            }

Was This Post Helpful? 0
  • +
  • -

#22 TechnoBear   User is online

  • 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 12 December 2018 - 06:48 AM

As much as I simply adore Glasgow kissing brick walls, we cannot help you much more until you provide the value types you're reviving compared against what you are expecting.

Let's take FormCode, is the DB expecting a string or some other data type?
Is the datatype coming out of FormCode.Text? (It'll literally be string, but are we expecting a number and is FormCode.Text "Hi" rather than "4", for example)
Does the expected datatype and actual datatype match?


Now answer these questions for each of them until you find the one that isn't matching up.
Was This Post Helpful? 0
  • +
  • -

#23 Sheepings   User is offline

  • Senior Programmer
  • member icon

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

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

Posted 12 December 2018 - 09:06 AM

It gets easier when you answer questions people are asking you.

What are the values of your textboxes/labels in your statement?
Did you add a reader like shown above?
Do you still need help?
Was This Post Helpful? 0
  • +
  • -

#24 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 - 11:50 AM

Sorry for late
values of my text boxes are string, double and int. i want to retrieve data from access database to form textboxes when i enter the Form Code in txtFormCode.text.
and i tried this but now;
System.InvalidCastException: 'Specified cast is not valid.'
this error appears

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);
				

				using (OleDbDataReader QueryReader = cmd.ExecuteReader())
				{
					while(QueryReader.Read())
					{
						[b]var FormCode = QueryReader.GetString(0);  //Error indicate here[/b]
					}
				}

				cmd.ExecuteReader();
				conn.Close();



and again i say that i try to use parameters 1st time so may be my mistakes are countless... so don't mind, and please still help me

This post has been edited by rizsoomro: 12 December 2018 - 11:50 AM

Was This Post Helpful? 0
  • +
  • -

#25 modi123_1   User is online

  • Suitor #2
  • member icon



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

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

Posted 12 December 2018 - 11:57 AM

I see the query uses these three parameters..
02
                OleDbCommand cmd = new OleDbCommand("Select * from Payment where [email protected] and [email protected] and [email protected] ", conn);
03
                 
04
                cmd.Parameters.AddWithValue("@FormCode", txtFormCode.Text);
05
                cmd.Parameters.AddWithValue("@ProjectName", lblProName.Text);
06
                cmd.Parameters.AddWithValue("@Status", "Active");
07



Then why are these here?
08
                cmd.Parameters.AddWithValue("@NameApplicant", txtCOName.Text);
09
                cmd.Parameters.AddWithValue("@FatherName",txtCOFName.Text);
10
                cmd.Parameters.AddWithValue("@CNICNo",txtCOCNIC.Text);
11
                cmd.Parameters.AddWithValue("@ApplicantAddress",txtCOAddres.Text);
12
                cmd.Parameters.AddWithValue("@MobileNo",txtCOMobile.Text);
13
                cmd.Parameters.AddWithValue("@ResidenceTel",txtCOResTel.Text);
14
                cmd.Parameters.AddWithValue("@PlotBanglowNo",txtPlotNo.Text);
15
                cmd.Parameters.AddWithValue("@Category",txtCategory.Text);
16
                cmd.Parameters.AddWithValue("@Type",txtPlotType.Text);
17
                cmd.Parameters.AddWithValue("@Block",txtPlotBlock.Text);
18
                cmd.Parameters.AddWithValue("@PlotSize",txtPlotSize.Text);



As an aside - you should not be storing your values in the GUI. The GUI should reflect values in a class or object. An important concept heading into the larger world of binding, WPF, DotNEtCore, etc.

Perfectly reasonable examples of reading into an adapter and the other doing UPDATE, INSERT, and DELETE.

https://www.dreaminc...-adapter-setup/
https://www.dreaminc...-command-setup/
Was This Post Helpful? 1
  • +
  • -

#26 Sheepings   User is offline

  • Senior Programmer
  • member icon

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

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

Posted 12 December 2018 - 12:24 PM

Lets do some tidying up, shall we. First move your parameters onto the 3rd line of the first set of using blocks I provided. Just the way I have it...

Secondly, you are providing more parameters than your statement represents. You can't do this.

If your statement represents 3 parameters, you should only have 3 parameters inside your command structure.

Remove these and try again ::
                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);




Only add these ::
                cmd.Parameters.AddWithValue("@FormCode", txtFormCode.Text);
                cmd.Parameters.AddWithValue("@ProjectName", lblProName.Text);
                cmd.Parameters.AddWithValue("@Status", "Active");

Because they are the only ones referenced by your statement ::
                OleDbCommand cmd = new OleDbCommand("Select * from Payment where [email protected] and [email protected] and [email protected] ", conn);

Consider this analogy; if you have 8 plugs and 1 socket (1 plug per socket), would you try to plug 8 plugs into the one socket? No
If Bob's bowl can store 6 apples in the bowl, should Bob put 22 apples in the bowl and risk them falling out or just put the six that he knows fit in the bowl? Not greatest analogies lol but I think you get it... that's what you're doing above.

It is also important to tell SPECIFICS;

View Postrizsoomro, on 12 December 2018 - 06:50 PM, said:

values of my text boxes are string, double and int.

Which textbox/or label is string, int, and double?

This post has been edited by Sheepings: 12 December 2018 - 12:47 PM

Was This Post Helpful? 0
  • +
  • -

#27 Skydiver   User is online

  • Code herder
  • member icon

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

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

Posted 12 December 2018 - 07:33 PM

View Postrizsoomro, on 12 December 2018 - 01:50 PM, said:

values of my text boxes are string, double and int. i want to retrieve data from access database to form textboxes when i enter the Form Code in txtFormCode.text.

We were not asking the types of the values in the textboxes. Technically, the type returned by TextBox.Text is a string, so they are all strings.

We were asking you the values in the textboxes. For example you could have responded with:

Quote

txtFormCode.Text contains the string "786213" and lblProName.Text contains the string "Bob's Used Cars"

Was This Post Helpful? 1
  • +
  • -

#28 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 - 05:22 AM

i remove and try this code but now error is;

ErrorSysterm.InvalidCaseException:Specified cast is not valid.
at System.Data.OleDb.ColumnBinding.ValueString()
at System.Data.OleDb.OleDbDataReader.GetString(Int32 ordinal)
at _[File Full path]: in line 236


try
			{


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

				using (OleDbDataReader QueryReader = cmd.ExecuteReader())
				{
					while (QueryReader.Read())
					{
						var FormCode = QueryReader.GetString(0); //This is line 236
					}
				}

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



SkyDriver yes your example is right
Was This Post Helpful? 0
  • +
  • -

#29 TechnoBear   User is online

  • 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 13 December 2018 - 06:54 AM

You need to answer the question of what values are in the textboxes and what value type the corresponding parameter is expecting. The problem is with trying to cast something to a type it cannot be.

If you do not answer this question we LITERALLY, not figuratively, cannot help you.
Was This Post Helpful? 0
  • +
  • -

#30 Sheepings   User is offline

  • Senior Programmer
  • member icon

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

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

Posted 13 December 2018 - 07:23 AM

View Postandrewsw, on 11 December 2018 - 01:14 PM, said:

Is FormCode a textual value?

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

andrewsw no this is numeric

Was This Post Helpful? 0
  • +
  • -

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