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 4:15am
sencsk1.1K
Edited 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
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 515
1 OriginalGriff 468
2 Abhinav S 305
3 sanket saxena 295
4 Tadit Dash 160
0 Sergey Alexandrovich Kryukov 8,482
1 OriginalGriff 4,830
2 Peter Leow 3,794
3 Maciej Los 3,515
4 Er. Puneet Goel 3,107


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