Syntax Question - Novice Question

S

sean

Hi,

I am filling a datagrid and I was wondering how I can test for "end of file"
and then make decisions based on that. I am still making the transition from
asp to asp.net.

Could someone help me with the syntax please?

Thanks in advance for youe answer

Sean



Dim Conn As OleDbConnection

Dim Rdr As OleDbDataReader

Try

Dim strConn As String = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE="

strConn &= Server.MapPath("clicks.mdb") & ";"

Dim strSQL As String

strSQL = "select FirstName from newsletter where FirstName='sean'"

Conn = New OleDbConnection(strConn)

Dim Cmd As New OleDbCommand(strSQL, Conn)

Conn.Open()

Rdr = Cmd.ExecuteReader()

MyDataGrid.DataSource = Rdr

MyDataGrid.DataBind()

Catch exc1 As Exception

Label1.Text = exc1.ToString()

Finally

If Not (Rdr Is Nothing) Then

If Rdr.IsClosed = False Then Rdr.Close()

End If

If Not (Conn Is Nothing) Then

If Conn.State = System.Data.ConnectionState.Open Then Conn.Close()

End If

End Try
 
C

Cowboy \(Gregory A. Beamer\)

The norm, in .NET, is to bind rather than curse through data.

// actual name of object goes after =
DataGrid1.DataSource = {DataSet, DataTable, DataView, DataReader};
DataGrid1.DataBind();

As such, you do not have to find EOF unless you are writing out the table
yourself. If you are aiming this direction, you will likely be using a
DataReader. The norm is to use a Do loop and loop as long as Read() returns
true.

Hope this helps.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

**********************************************************************
Think Outside the Box!
**********************************************************************
 

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

Members online

Forum statistics

Threads
473,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top