TechTalkz.com Logo Ask the Experts!

Go Back   TechTalkz.com Technology & Computer Troubleshooting Forums > Tech Support Archives > Programing Languages > VB.NET

Simple ADO.Net Recordset.

VB.NET

 
 
Thread Tools Display Modes
Unread 05-09-2007, 09:21 AM   #1
Greg
Guest
 
Posts: n/a
Simple ADO.Net Recordset.

My background is in MS Access and I am in the process of migrating my
skillsets to Visual Basic.Net. So far I am able to display data in
DataGridViews and Combo Box, etc with not problem. What I'm not so sure about
is bullding a recordset so that I can iterate through the record set and
perform tasks. I guess this would be a dataset or a table adapter. How would
I basically achieve a code module that does the same as the code below?

Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
rst.Open "stored procedure/table", CurrentProject.Connection,
adOpenDynamic, adLockOptimistic
Do Until rst.EOF
rst.AddNew
' Add, edit, delete or just read data here.
rst.Update
rst.Delete
rst.MoveNext
Loop

This is how I step through records from Access using SQL Server. How would I
achieve basically the same thing in Visual Basic.Net? Or, can someone provide
a simple snapshot of the equivilant for VB.Net?

Thank you.
 
Unread 05-09-2007, 09:21 AM   #2
Dieter Inscheidt
Guest
 
Posts: n/a
Re: Simple ADO.Net Recordset.

I guess that letting VB convert your VB6 project automatically is the
smartest thing you could do.
Select "open" in the file menu, then choose your existing VB6 project
that contains the code you want to have converted.
Cheers,
Dieter
 
Unread 05-09-2007, 09:21 AM   #3
josephshamiltons@gmail.com
Guest
 
Posts: n/a
Re: Simple ADO.Net Recordset.

On Aug 31, 9:00 pm, "Ralph" <nt_consultin...***********> wrote:
> "Greg" <AccessVBA...@newsgroups.nospam> wrote in message
>
> newsBC23B53-B5D1-4512-AA91-0B3918982BC2@microsoft.com...
>
>
>
> > My background is in MS Access and I am in the process of migrating my
> > skillsets to Visual Basic.Net. So far I am able to display data in
> > DataGridViews and Combo Box, etc with not problem. What I'm not so sure

> about
> > is bullding a recordset so that I can iterate through the record set and
> > perform tasks. I guess this would be a dataset or a table adapter. How

> would
> > I basically achieve a code module that does the same as the code below?

>
> > Dim rst As ADODB.Recordset
> > Set rst = New ADODB.Recordset
> > rst.Open "stored procedure/table", CurrentProject.Connection,
> > adOpenDynamic, adLockOptimistic
> > Do Until rst.EOF
> > rst.AddNew
> > ' Add, edit, delete or just read data here.
> > rst.Update
> > rst.Delete
> > rst.MoveNext
> > Loop

>
> > This is how I step through records from Access using SQL Server. How would

> I
> > achieve basically the same thing in Visual Basic.Net? Or, can someone

> provide
> > a simple snapshot of the equivilant for VB.Net?

>
> > Thank you.

>
> There's a couple of zillion out there.
> Are you using VB 2005 Express or Std/Pro? Or something else?
> When you start up the IDE ...
> "Getting Started" box select "How Do I ...?" and select Data Access.
>
> Here is a quick snapshot:http://asp.dotnetheaven.com/howto/do...employees.aspx
>
> Standard Warning! ADO.Net looks like ADO, but it ain't. Don't make
> assumptions. Treat it like a new ballgame. <g>
>
> hth
> -ralph


Dim rst As ADODB.Recordset
> > Set rst = New ADODB.Recordset
> > rst.Open "stored procedure/table", CurrentProject.Connection,
> > adOpenDynamic, adLockOptimistic
> > Do Until rst.EOF
> > rst.AddNew
> > ' Add, edit, delete or just read data here.
> > rst.Update
> > rst.Delete
> > rst.MoveNext
> > Loop


Dim conn as new SqlConnection(connectionString)
Dim comm as new SqlCommand(query,conn)
Dim reader as SqlDataReader= comm.ExecuteReader()

dim variable as string

while reader.read
variable = reader("ColumnName")

end while



'use this for an query that is not a select

comm.CommandText = "Update table set values('" + value +"'"
comm.ExecuteNonQuery

The reader allows you forward only access to a recordset.

Use a datatable or dataset for a disconnected very intuitive model of
a database or a databasetable.

 
Unread 05-09-2007, 09:21 AM   #4
Ralph
Guest
 
Posts: n/a
Re: Simple ADO.Net Recordset.


"Greg" <AccessVBAnet@newsgroups.nospam> wrote in message
newsBC23B53-B5D1-4512-AA91-0B3918982BC2@microsoft.com...
> My background is in MS Access and I am in the process of migrating my
> skillsets to Visual Basic.Net. So far I am able to display data in
> DataGridViews and Combo Box, etc with not problem. What I'm not so sure

about
> is bullding a recordset so that I can iterate through the record set and
> perform tasks. I guess this would be a dataset or a table adapter. How

would
> I basically achieve a code module that does the same as the code below?
>
> Dim rst As ADODB.Recordset
> Set rst = New ADODB.Recordset
> rst.Open "stored procedure/table", CurrentProject.Connection,
> adOpenDynamic, adLockOptimistic
> Do Until rst.EOF
> rst.AddNew
> ' Add, edit, delete or just read data here.
> rst.Update
> rst.Delete
> rst.MoveNext
> Loop
>
> This is how I step through records from Access using SQL Server. How would

I
> achieve basically the same thing in Visual Basic.Net? Or, can someone

provide
> a simple snapshot of the equivilant for VB.Net?
>
> Thank you.


There's a couple of zillion out there.
Are you using VB 2005 Express or Std/Pro? Or something else?
When you start up the IDE ...
"Getting Started" box select "How Do I ...?" and select Data Access.

Here is a quick snapshot:
http://asp.dotnetheaven.com/howto/do...employees.aspx

Standard Warning! ADO.Net looks like ADO, but it ain't. Don't make
assumptions. Treat it like a new ballgame. <g>

hth
-ralph


 
Unread 05-09-2007, 09:21 AM   #5
Linda Liu [MSFT]
Guest
 
Posts: n/a
RE: Simple ADO.Net Recordset.

Hi Greg,

Joseph has given the equivilant code snipet for ADO.NET.

In ADO you scan sequentially through the rows of the recordset using the
ADO MoveNext method. In ADO.NET, rows are represented as collections, so
you can loop through a table as you would through any collection, or access
particular rows via ordinal or primary key index.

Alternatively, you can use the ADO.NET DataReader to retrieve a read-only,
forward-only stream of data from a database. Results are returned as the
query executes, and are stored in the network buffer on the client until
you request them using the Read method of the DataReader.

Using the DataReader can increase application performance both by
retrieving data as soon as it is available, rather than waiting for the
entire results of the query to be returned, and (by default) storing only
one row at a time in memory, reducing system overhead. Of course, in this
case, if you want to save changes back to the database, you need to use
SqlCommand object to do it.

For more information on ADO.NET, you may refer to the following MSDN
documents:

'Comparison of ADO.NET and ADO'
http://msdn2.microsoft.com/en-us/lib...4k(vs.71).aspx

'Introduction to Data Access with ADO.NET'
http://msdn2.microsoft.com/en-us/lib...kt(vs.71).aspx

'Retrieving Data Using the DataReader'
http://msdn2.microsoft.com/en-us/lib...05(VS.71).aspx

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

 
Unread 05-09-2007, 09:21 AM   #6
Linda Liu [MSFT]
Guest
 
Posts: n/a
RE: Simple ADO.Net Recordset.

Hi Greg,

I'm reviewing this post and would like to know the status of this issue.

If you have any question, please feel free to let me know.

Thank you for using our MSDN Managed Newsgroup Support Service!

Sincerely,
Linda Liu
Microsoft Online Community Support

 
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple?? sparkster Microsoft Office 1 28-08-2007 07:02 AM
Simple?? sparkster Microsoft Office 1 28-08-2007 06:59 AM
simple search jjLL Windows Vista All 5 19-08-2007 05:56 PM
Ok. Simple question. Tomster Windows XP 6 16-08-2007 09:59 AM
A Simple Question Lou Windows XP 4 15-08-2007 02:39 PM


< Home - Windows Help - MS Office Help - Hardware Support >


New To Site? Need Help?

All times are GMT. The time now is 02:08 AM.


vBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO
Copyright © 2005-2013, TechTalkz.com. All Rights Reserved - Privacy Policy
Valid XHTML 1.0 Transitional