Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB8.0
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnview.Click
connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=G:\db1.mdb;Persist Security Info=False"
conn.Open(connectionstring)
rs.Open("select * from table1 where Name='" & snm.Text & "'")
' If rs.EOF Then
'rs.AddNew()
 
'End If
 
conn = New ADODB.Command
 
If Not rs.EOF Then
sid.Text = rs.Fields(0)
snm.Text = rs.Fields("Name")
sadd.Text = rs.Fields("Address")
scno.Text = rs.Fields("Contact_Number")
svat.Text = rs.Fields("Vat")
 

'rs.Fields(0) = sid.Text
'rs.Fields(1) = snm.Text
'rs.Fields(2) = sadd.Text
'rs.Fields(3) = scno.Text
'rs.Fields(4) = svat.Text
Else
sid.Text = ""
snm.Text = ""
sadd.Text = ""
scno.Text = ""
svat.Text = ""
 

End If
'rs.Close()
rs = Nothing
 
MsgBox("done")
 
End Sub 
 
This is my code.
I get an error "Runtime errors might occur when converting 'ADODB.Field' to 'String'", how can I solve this issue?
Posted 12-Jul-10 5:15am
sencsk1.2K
Edited 12-Jul-10 5:19am
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Try rs.Fields(0).ToString(). Hope that's it: don't use VB but should be similar.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 13 Jul 2010
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100