Syntax Question - Novice Question

Discussion in 'ASP .Net' started by sean, Oct 20, 2003.

  1. sean

    sean Guest

    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
    sean, Oct 20, 2003
    #1
    1. Advertising

  2. 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!
    **********************************************************************
    "sean" <> wrote in message
    news:OZ0t%...
    > 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
    >
    >
    >
    Cowboy \(Gregory A. Beamer\), Oct 20, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ra

    VHDL novice question

    ra, Jul 13, 2004, in forum: VHDL
    Replies:
    6
    Views:
    2,819
    Allan Herriman
    Jul 13, 2004
  2. sean
    Replies:
    0
    Views:
    302
  3. sean
    Replies:
    2
    Views:
    528
    Kevin Spencer
    Dec 2, 2003
  4. sean

    Forms question - Novice

    sean, Feb 2, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    311
    Steve C. Orr [MVP, MCSD]
    Feb 2, 2004
  5. =?Utf-8?B?QXNob2s=?=

    DataSet - Novice Question

    =?Utf-8?B?QXNob2s=?=, Feb 14, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    308
    Scott Allen
    Feb 14, 2004
Loading...

Share This Page