Newbie - ADO

  • Thread starter Thread starter NewsGroups
  • Start date Start date
N

NewsGroups

I am starting to get up to speed on VB NET, but I seem to keep having
trouble with one or two areas.

The latest one is reading databases (Access/SQL Server).

In the past I have set up connections with :-

Dim dbDatabase As Connection
Dim rsNames As Recordset

Set dbDatabase = New Connection
Set rsNames = New Recordset

sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;"
sConnection = sConnection & "Persist Security Info=False;"
sConnection = sConnection & "Data Source=" & App.Path & "\names.mdb"

dbDatabase.ConnectionString = sConnection
dbDatabase.Open

rsNames.CursorType = adOpenKeyset
rsNames.LockType = adLockOptimistic
rsNames.Open "select * from Names", dbDatabase

Then I have Buttons with Find.Next, Prior, Last, First, to allow the users
to navigate the database

I cant seem to find similar in .Net

Any Advice/help please

Thanks


Derrick
 
Hi Newbie,

When you are a Newbie, forget everything about the recordset and Ado. Go go
AdoNet and use the dataset.

Not the only advantage, but the dataset is much easier to handle than the
recordset

Just my thought,

Cor
 
I have tried using some examples, but they are all bound to controls, which
I dont always need?
 
Hi Herfried,
[ADO stuff]

<URL:news://news.microsoft.com/microsoft.public.dotnet.framework.adonet>

Are you sure of that?

I think for Ado and VB.net is no other newsgroup than this one, but helping
a "newby" with Ado, is helping someone in the wrong direction in my opinion.

Cor
 
* "Cor said:
[ADO stuff]

<URL:news://news.microsoft.com/microsoft.public.dotnet.framework.adonet>

Are you sure of that?

I think for Ado and VB.net is no other newsgroup than this one, but helping
a "newby" with Ado, is helping someone in the wrong direction in my opinion.

IMO the OP should rethink his choice of ADO and switch to ADO.NET
directly.

Just my 2 cents.
 
I am starting to get up to speed on VB NET, but I seem to keep having
trouble with one or two areas.

The latest one is reading databases (Access/SQL Server).


An excellent book on ADO.Net is from Microsoft Press by David Sceppa. It's
called (coincidentally enough) "ADO.Net". I think it is the best book
around for learning ADO.Net.

Just thought you'd be interested.
 
I am starting to get up to speed on VB NET, but I seem to keep having
Derrick,

Just for drill, here is the code used to make a call to a stored
procedure and return a dataset with ADO.NET. Don't be put off by what
looks like complexity, you can put it in a class and use it over and
over again with just a line or two of code. Once you get the
structure down you'll see that ADO.NET is actually pretty
straightforward and much more flexible than classic ADO.

Charlie

Imports System.Data.SqlClient

Public mConnection As SqlConnection
Public mobjCommand As SqlCommand
Public mobjDataSet As DataSet
Public mobjDataAdapter As SqlDataAdapter
Public spName as string ="Stored procedure name"

mConnection = New SqlConnection("connection string goes here")

mobjDataSet = New DataSet

mobjCommand = New SqlCommand(spName, mConnection)

mobjCommand.CommandType = CommandType.StoredProcedure
mobjCommand.Parameters.Clear()

objData.mobjCommand.Parameters.Add("@parametername", parametervalue)

mobjDataAdapter = New SqlDataAdapter(mobjCommand)

mConnection.Open()

mobjDataAdapter.Fill(mobjDataSet)

mConnection.Close()
 
Back
Top