Hi

I am new to vb.net using visual studio. I'm having a hard time trying to figure out the new syntax for vb.net

The following is code is what I'm trying to create in vb.net

Set cnGblBatch = New ADODB.Connectio
cnGblBatch.ConnectionString = "Provider=SQLOLEDB;Server=;Database=;UID=;PWD=;
cnGblBatch.Ope

Set rsBatch = cnGblBatch.Execute("select * from person"

Do While Not rsBatch.EO

sFirstName = rsBatch!FirstName
sMI = rsBatch!M
sLastName = rsBatch!LastNam
sAddr1 = rsBatch!Addres
sCity = rsBatch!Cit
sState = rsBatch!Stat
sZip = rsBatch!Zi

rsBatch.MoveNex

Loo

rsBatch.Clos

Any help would be appreciated

Re: Help with reading SqlDataReader by William

William
Wed Jun 02 19:38:53 CDT 2004

Dim cn as New SqlConnection("ConnectionStringHere")
Dim cmd as New SqlCommand("SQLStatement", cn)
Dim dr as SqlDataReader

dr = cmd.ExecuteReader

While dr.Read
sFirstName = dr.GetString(0) ' 0 is the index of the first columname in
your SQL Statement
sLastName = dr.GetString(1)
End While


"beecherw" <william_beecher@irv.wunderman.com> wrote in message
news:CB489F0E-44AD-4DE0-9575-7153C9357FF3@microsoft.com...
> Hi,
>
> I am new to vb.net using visual studio. I'm having a hard time trying to
figure out the new syntax for vb.net.
>
> The following is code is what I'm trying to create in vb.net:
>
>
> Set cnGblBatch = New ADODB.Connection
> cnGblBatch.ConnectionString =
"Provider=SQLOLEDB;Server=;Database=;UID=;PWD=;"
> cnGblBatch.Open
>
> Set rsBatch = cnGblBatch.Execute("select * from person")
>
> Do While Not rsBatch.EOF
>
> sFirstName = rsBatch!FirstName
> sMI = rsBatch!MI
> sLastName = rsBatch!LastName
> sAddr1 = rsBatch!Address
> sCity = rsBatch!City
> sState = rsBatch!State
> sZip = rsBatch!Zip
>
> rsBatch.MoveNext
>
> Loop
>
> rsBatch.Close
>
>
> Any help would be appreciated!
>

--
W.G. Ryan MVP Windows - Embedded

http://forums.devbuzz.com
http://www.knowdotnet.com/dataaccess.html
http://www.msmvps.com/williamryan/



Re: Help with reading SqlDataReader by Cor

Cor
Thu Jun 03 02:57:07 CDT 2004

Hi Beecherew,

I give an alternative to Bills code because I saw you where using the
recordset method which looks more on the dataset method than the datareader.
The method from Bill works as well.

Dim cn as New SqlConnection("ConnectionStringHere")
Dim cmd as New SqlCommand("SQLStatement", cn)
Dim dr as SqlDataReader
dim ds as new dataset
dim da as new SQLDataAdapter(cmd)
da.fill(ds)
dim dr as datarow = ds.tables(0).rows(0)
sFirstName = dr("FirstName")
sMi = dr("MI")
etc.

I hope this helps?

Cor