Click here to Skip to main content
15,868,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
Updated 15-Mar-18 15:20pm
v2

Try rs.Fields(0).ToString(). Hope that's it: don't use VB but should be similar.
 
Share this answer
 
in C# rs.Fields[0].Value.ToString();
 
Share this answer
 
Comments
Richard Deeming 16-Mar-18 13:28pm    
EIGHT YEARS too late.

And anyone who's using C# is unlikely to still be using such an ancient and long-dead technology as ADO; they'll at least be using ADO.NET instead.

Stick to answering recent questions.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900