Click here to Skip to main content
12,957,007 members (59,297 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
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 4:15am
sencsk1.4K
Updated 12-Jul-10 4: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)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 6,924
CHill60 3,550
Maciej Los 3,312
ppolymorphe 2,120
Jochen Arndt 1,973


Advertise | Privacy | Mobile
Web02 | 2.8.170525.1 | Last Updated 13 Jul 2010
Copyright © CodeProject, 1999-2017
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