OLEDB update error

Data type mismatch in criteria expression

Page 1 of 1

1 Replies - 3268 Views - Last Post: 13 November 2008 - 07:55 PM Rate Topic: -----

#1 sacwchiri   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 27-March 07

OLEDB update error

Posted 13 November 2008 - 07:36 PM

Hi there im trying to update a row in an access database but every time i do the update statement seems to give me an Data type mismatch error, im pretty sure im entering the right data since i went and tested a single field so if anyone can give me a hand and figure out why this is happening.

 public int updateUser()
		{
			int altered = 0;
			int fullRut = ((Rut * 10) + Int32.Parse(ValRut.ToString()));
			string cmdText = "UPDATE persona SET id_ecivil = 2 WHERE rut = 32562166";
								//"rut = " + fullRut + ", " + 
								//"nombres = '" + Names + "' " + 
								//"ap_paterno = '" + LastName + "', " + 
								//"ap_materno = '" + SecondLast + "', " + 
								//"email = '" + Email + "', " +
								//"id_sexo = " + Sex + ", " + 
								//"id_ecivil = " + Status + ", " + 
								//"id_comuna = " + Comuna + ", " +
								//"direccion = '" + Address + "', " + 
								//"fono = '" + Phone + "' " +
								//"WHERE rut = " + fullRut;


			OleDbConnection myCon = null;
			OleDbCommand myComm = null;
			
			try
			{
				myCon = new OleDbConnection(_ConnectionStr);
				myComm = new OleDbCommand(cmdText, myCon);

				myCon.Open();
				
				altered = myComm.ExecuteNonQuery();

			}

			catch(OleDbException exp)
			{
				string errorMessages;
				for (int i = 0; i < exp.Errors.Count; i++)
				{
					errorMessages = "Index #" + i + "\n" +
									 "Message: " + exp.Errors[i].Message + "\n" +
									 "NativeError: " + exp.Errors[i].NativeError + "\n" +
									 "Source: " + exp.Errors[i].Source + "\n" +
									 "SQLState: " + exp.Errors[i].SQLState + "\n";
					Console.WriteLine(errorMessages);
				}

			}

			finally
			{
				myCon.Close();
			}

			return altered;
		}



thanx in advance :)

Is This A Good Question/Topic? 0
  • +

Replies To: OLEDB update error

#2 sacwchiri   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 27-March 07

Re: OLEDB update error

Posted 13 November 2008 - 07:55 PM

Oh well nvm found the problem someone had change the type of the field for rut in the db -_- and i did not notice. Thats what happens when you are to tired to program and begin to make mistakes hahaha.

Thanx anyway ^^
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1