Click here to Skip to main content
11,931,104 members (58,308 online)
Rate this:
Please Sign up or sign in to vote.
See more: VB8.0 VB
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 5:15am
Edited 12-Jul-10 5: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 | Mobile
Web02 | 2.8.151126.1 | Last Updated 13 Jul 2010
Copyright © CodeProject, 1999-2015
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