Click here to Skip to main content
13,143,185 members (57,675 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"
rs.Open("select * from table1 where Name='" & snm.Text & "'")
' If rs.EOF Then
'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
sid.Text = ""
snm.Text = ""
sadd.Text = ""
scno.Text = ""
svat.Text = ""

End If
rs = Nothing
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
Updated 12-Jul-10 4:19am

1 solution

Rate this: bad
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.

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

Advertise | Privacy |
Web04 | 2.8.170915.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