3 Replies - 3654 Views - Last Post: 17 August 2012 - 08:09 AM Rate Topic: -----

#1 TFPTECH  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 15-August 12

Run-time error'40002'

Posted 16 August 2012 - 09:04 AM

'THE 3 LINES OF BELOW SHOW THE KIND OF MESSAGE I AM GETTING WHEN I TRY TO SEND DATA TO THE DATABASE
' I HAVE LEBELED THE 1, 2, 3
'1. Run-time error'40002'

'2. s1000: [MySQL][ODBC 3.51 Driver][mysqld-5.5.24]Incorect
'3. value: 'Text2' for age at row 1
Option Explicit
Dim cnMySql As New rdoConnection
Dim rdoQry As New rdoQuery
Dim rdoRS As rdoResultset
Dim Text2 As String
Dim age As Integer

Private Sub Form_Load()
cnMySql.CursorDriver = rdUseOdbc
cnMySql.Connect = "uid=root;pwd=moses12;server=localhost;driver={MySQL ODBC 3.51 Driver};database=SRMS;dsn=SRMS;"
End Sub
Private Sub cmdSave_Click()
Text2 = age
If age >= 6 Then
'Text4(1).Text = Text4(1).Text + 1
cnMySql.EstablishConnection
With rdoQry
.Name = "root"
.SQL = "insert into regstudent (n_Student,age,sex,nationality,p_birth,d_birth,religion,f_name,tel,occupation,w_place,F_address,m_name,tel2,occupation2,w_place2,F2_address,prev_school,Location,grade_attained,aggregates,code) values ('Text1','Text2','Text3','Text4','Text5','Text6','Text7','Text8','Text9','Text10','Text11','Text12','Text13','Text14','Text15','Text16','Text17','Text18','Text19','Text20','Text21','Text22')"

'.SQL = "Insert into regstudent (admin,tester,user2,user3,user4) VALUES ('101','202','303','404','505')"
Set .ActiveConnection = cnMySql
'THIS LINE IS HIGHLIGHTED YOLEW
Set rdoRS = .OpenResultset(rdOpenKeyset, rdConcurRowVer)
End With
rdoRS.Close
cnMySql.Close
 
'End If
End Sub



Is This A Good Question/Topic? 0
  • +

Replies To: Run-time error'40002'

#2 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 299
  • View blog
  • Posts: 1,768
  • Joined: 26-March 09

Re: Run-time error'40002'

Posted 17 August 2012 - 07:33 AM

The first question, is what is the DataType of Age in your database?
Was This Post Helpful? 0
  • +
  • -

#3 TFPTECH  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 15-August 12

Re: Run-time error'40002'

Posted 17 August 2012 - 07:52 AM

View Postmaj3091, on 17 August 2012 - 07:33 AM, said:

its an integer in the MYSQL table

Was This Post Helpful? 0
  • +
  • -

#4 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 299
  • View blog
  • Posts: 1,768
  • Joined: 26-March 09

Re: Run-time error'40002'

Posted 17 August 2012 - 08:09 AM

Then try writing an integer to it and not a string.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1