4 Replies - 1161 Views - Last Post: 09 December 2009 - 06:02 AM Rate Topic: -----

#1 pharaon  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 164
  • Joined: 18-October 07

HELP with ADODB code

Post icon  Posted 08 December 2009 - 03:44 AM

i get this Error
run-time error '13':
type mismatch

Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Private Sub Command1_Click()
list.ListItems.Clear
list.ColumnHeaders.Clear
list.ColumnHeaders.Add , , "Name"
list.ColumnHeaders.Add , , "Telephone"
list.ColumnHeaders.Add , , "Address"
list.GridLines = True
list.View = lvwReport
rs.MoveFirst
Do Until rs.EOF
Set ListItems = list.ListItems.Add(, , rs!user)
If rs.Fields!phone = "" Then
ListItems.SubItems(1) = ""
Else
ListItems.SubItems(1) = rs.Fields!phone
End If
If rs.Fields!adress = "" Then
ListItems.SubItems(2) = ""
Else
ListItems.SubItems(2) = rs.Fields!adress
End If
rs.MoveNext
Loop
End Sub

Private Sub Form_Load()
cn.Open "provider=microsoft.jet.oledb.4.0;data source=test.mdb"
rs.Open "test", cn, 1, 3
End Sub


can some one tell me what is wrong?

Is This A Good Question/Topic? 0
  • +

Replies To: HELP with ADODB code

#2 theunborncoder  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 13
  • View blog
  • Posts: 123
  • Joined: 15-October 09

Re: HELP with ADODB code

Posted 08 December 2009 - 05:06 AM

you can check exact problem by setting your error mode to "Break on all errors" this mode will raise exact error code and show you location of error

to set this mode right click on any form (no design code area) and
Toggle -> "Break on all errors"
Was This Post Helpful? 0
  • +
  • -

#3 pharaon  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 164
  • Joined: 18-October 07

Re: HELP with ADODB code

Posted 08 December 2009 - 02:56 PM

guys i'm still bignner in vb6 so please some one check this code and tell me what is the right code to fix it
Was This Post Helpful? 0
  • +
  • -

#4 Nash29  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 24
  • Joined: 17-November 09

Re: HELP with ADODB code

Posted 09 December 2009 - 05:20 AM

View Postpharaon, on 8 Dec, 2009 - 02:44 AM, said:

i get this Error
run-time error '13':
type mismatch


As its showing type mismatch error, it means the problem is in data type. May be the problem must be occurring while trying to enter the value in phone field. I think you must have given Numeric type in the database and in code providing string type to the field.

Try this :
ListItems.SubItems(1) = Val(rs.Fields!phone)


I hope it works.. :)
Was This Post Helpful? 0
  • +
  • -

#5 pharaon  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 164
  • Joined: 18-October 07

Re: HELP with ADODB code

Posted 09 December 2009 - 06:02 AM

i attached the project
i get the error when some fileds is empty of data
so how can i make the program work even if some fileds is empty of data

Attached File(s)

  • Attached File  test.zip (11.35K)
    Number of downloads: 79

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1