Ado.net

A

acko bogicevic

Hi I complityly new in .NET and have a lot of problems
I would like to do basic task:
1) Open connection
2) fill data set
3) find out if dataset is bof or eof but in ado net there is no bof and
eof property haw can i do this task
Here is my code

Dim CN As New SqlConnection
Dim DA As New SqlDataAdapter
Dim DS As New DataSet
Dim cmd As New SqlClient.SqlCommand


Dim strSQL As String
dim cnString as String

cnString = "someString"
strSQL = "SELECT SUBJEKT,GESLO from CONTACTS " _
& " WHERE USERID = '" & UserName & "'"

CN.ConnectionString = cnString
cmd.CommandText = strSQL
cmd.CommandType = CommandType.Text
cmd.Connection = CN

CN.Open()


DA.SelectCommand = cmd
DA.SelectCommand.ExecuteNonQuery()

Try

DA.Fill(DS)


Catch ex As Exception

End Try

Here i want to ask for dataset if it is bof or eof

Thanks
Aleksandar


acko
 
A

Armin Zingler

acko bogicevic said:
Hi I complityly new in .NET and have a lot of problems
I would like to do basic task:

There is no EOF or BOF. A datatable holds the records. The records can be
indexed. Use the count property of the Datatable's Row property to get the #
of records.

Further ADO.NET questions: microsoft.public.dotnet.framework.adonet
 
C

Cor

Hi Acko,
This dataset of you is a simple table,
So some code rough typed, so if there are errors check it but this is the
idea's.
\\\
ds.tables.count = 0 'there is no table
///
\\\
ds.tables(0).rows.count > 0 ' there is minium 1 row
///
\\\
ds.tables(0).rows(0) ' the first row
///
\\\
ds.tables(0).rows(index)=ds.tables(0).rows.count-1 'the last row
///
I hope this helps a little bit?
Cor
 
E

emanuele ranciaffi

Hi, you can read this example too:

Imports System.Data
Imports System.Data.SqlClient

Dim cnn As IDbConnection = New SqlConnection(strcnn)

cnn.Open()
strSQL="" 'some SELECT


Dim cmd As New SqlCommand(strSQL, cnn)
Dim dr As SqlDataReader = cmd.ExecuteReader()

Do While dr.Read 'loop for read all records affect
Loop

or

If dr.Read Then
'# of records are > 0
Else
'# of records are = 0
End If

cnn.Close()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top