[RESOLVED] ADO to ADO.Net coding(vb)
In VB6 I did this
Code:
oFile rsUpd, "select * from blankvars"
With rsUpd
.MoveFirst
Do While Not .EOF
![oldcode] = gtID & ![oldcode]
.MoveNext
Loop
.Close
End With
SImply put I replace a column of data in a table updating as I go then close it.
It's an Access .mdb & OFile opens the recordset.
I would like to do the same but now using vb2010/ADO.Net. I must be missing something simple but any help appreciated.
Re: ADO to ADO.Net coding(vb)
In .Net there is completely different object model - perhaps this msdn article will get you started.
Re: ADO to ADO.Net coding(vb)
This is the closest equivalent in VB.Net:-
vbnet Code:
'
Dim conn As New SqlConnection("Data Source=intel32;Integrated Security=True;Initial Catalog=DbSimple")
Dim cmd As New SqlCommand("Select * From Tbl1", conn)
conn.Open()
Dim reader As SqlDataReader = cmd.ExecuteReader
Do While reader.Read
'Shows the value of the first column
MsgBox(reader.GetInt32(0))
Loop
There are no RecordSets in VB.Net so we can't write back to the database that way. Much has changed. You should really study the link RhinoBull posted.
Re: ADO to ADO.Net coding(vb)
Thanks Guys,
I'm ploughing through all the links and my heads all over the place. I'm finding vb.net much harder than I thought, things that used to be easy now seem so long winded. But I will persevere. Thanks for your help.
Re: [RESOLVED] ADO to ADO.Net coding(vb)
Actually, after some time you would find that doing stuff in VB.Net is far easier and you can do so much more.