2 Replies - 5223 Views - Last Post: 02 September 2013 - 07:50 AM Rate Topic: -----

#1 samzfrter   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 11-July 13

conversion from string to integer is not valid.

Posted 01 September 2013 - 05:48 AM

My UPDATE code below displays the error:


"UPDATE tblstaff SET fName='name'to type 'integer'is not valid.Microsoft.VisualBasic"

 If conn.State = ConnectionState.Open Then
com = New OleDb.OleDbCommand("SELECT *FROM tblstaff ")
  com.Connection = conn
Dim cb As New OleDb.OleDbCommandBuilder(da)
 da.Fill(ds, "Eeestaffinfo")
 Dim sql As String = String.Format("UPDATE tblstaff SET fName='{1}', lName='{2}', dob=#{3}#, eMail='{4}', 

mobileNo='{5}', designation='{6}', address='{7}', fAppointment=#{8}#, fpromotion=#{9}#, lpromotion=#{10}#, 

publications='{11}', position='{12}', leaveStatus='{13}' WHERE pfNumber='{0}'", txtPfNo.Text, txtFname.Text, 

txtLname.Text, Format(dtpDob.Value, "dd/MM/yyyy"), txtEmail.Text, txtPno.Text, txtDesignat.Text, txtAddress.Text, 

Format(dtpFappoint.Value, "dd/MM/yyyy"), Format(dtpFpromo.Value, "dd/MM/yyyy"), Format(dtpLpromo.Value, "dd/MM

/yyyy"), txtPublicatn.Text, txtPosition.Text, txtLstatus.Text)
 com.CommandType = sql
 com.CommandType = CommandType.Text
 com.Connection = conn
 End If
 Catch ex As Exception
 MessageBox.Show(ex.Message & " " & ex.Source)
 End Try

The query statement produces the required values when i debug the program but with the error message described above,the changes are not effected in the ms Access.

This post has been edited by andrewsw: 01 September 2013 - 06:00 AM
Reason for edit:: Please use CODE tags

Is This A Good Question/Topic? 0
  • +

Replies To: conversion from string to integer is not valid.

#2 andrewsw   User is offline

  • blow up my boots
  • member icon

Reputation: 6544
  • View blog
  • Posts: 26,531
  • Joined: 12-December 12

Re: conversion from string to integer is not valid.

Posted 01 September 2013 - 06:25 AM

Print out the string-value sql (using Debug.Print) and try to execute the statement directly in Access.

It is likely that either the order of the arguments, or a data-type, is incorrect but it is hard to read this long statement. You should use parameterized queries.
Was This Post Helpful? 0
  • +
  • -

#3 deery5000   User is offline

  • D.I.C Lover

Reputation: 87
  • View blog
  • Posts: 1,097
  • Joined: 09-May 09

Re: conversion from string to integer is not valid.

Posted 02 September 2013 - 07:50 AM

might be just a type mismatch

check the types in your database within the table against the values your passing in this method
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1