Unbound Access Data Source

Discussion in 'ASP .Net' started by Chip Pearson, Jul 3, 2007.

  1. Chip Pearson

    Chip Pearson Guest

    I'm sure I'm missing something simple, but I've hit a brick wall. I'm
    creating an ASP.NET 2.0 web site in VS2005 (VB.NET) and need to read data
    from an Access database without attaching it to any UI control. I've dropped
    an AccessDataSource control named AccessGetDescription on my aspx page and
    configured the data source with an SQL SELECT statement. Now, how in code
    do I loop through the returned records? Here's what I have so far:

    Dim IEnum As IEnumerable
    Dim ThisFile As String
    Dim ???? As ????
    ThisFile = "Whatever.xls"
    With Me.AccessGetDescription
    .SelectCommandType = SqlDataSourceCommandType.Text
    .SelectCommand = "SELECT Description FROM TableName WHERE FileName =
    ThisFileName"
    .SelectParameters.Add("ThisFileName", ThisFile)
    IEnum = .Select(DataSourceSelectArguments.Empty)
    For Each ???? In ????
    MyDesc = ???.Fields("Description").ToString()
    Next ???
    End With

    What goes after the .Select method and how are the variables declared to
    loop through all the records? I'm used to ADO where you can do a

    Do Until RecSet.EOF()
    Debug.Print RecSet.Fields("Whatever").Value
    RecSet.MoveNext
    Loop

    I can't get this to work in ASP.NET 2.0.

    Any suggestions would be greatly appreciated. Thank you very much.


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting
    www.cpearson.com
    (email on the web site)
    Chip Pearson, Jul 3, 2007
    #1
    1. Advertising

  2. Chip Pearson

    Mark Rae Guest

    "Chip Pearson" <> wrote in message
    news:...

    > Do Until RecSet.EOF()
    > Debug.Print RecSet.Fields("Whatever").Value
    > RecSet.MoveNext
    > Loop


    Are you trying to use ADO instead of ADO.NET...?

    If you're not doing any databinding, I would strongly advise not using any
    of the DataSource objects at all.

    Instead, just use ADO.NET to fetch a DataSet from your Jet database...
    http://www.asp101.com/articles/jay/adodotnet/part3.asp


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
    Mark Rae, Jul 3, 2007
    #2
    1. Advertising

  3. Chip Pearson

    Chip Pearson Guest

    >> Do Until RecSet.EOF()
    >> Debug.Print RecSet.Fields("Whatever").Value
    >> RecSet.MoveNext
    >> Loop

    >
    > Are you trying to use ADO instead of ADO.NET...?


    That code was just an example of what I am used to doing (in VB6 and VBA),
    not what I'm doing now. Yes, I'm using ADO.NET. The link you posted was
    interesting, but it still relied on binding the data source to a control, in
    this case the DataGrid. I do NOT want to bind to any control. All I want to
    do is a FOR loop iterating through the returned records one at a time,
    examining the various fields of each record.

    I would be very grateful if you could post some working code that iterates
    through the result records of a SELECT without (!) binding to any control.


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting
    www.cpearson.com
    (email on the web site)


    "Mark Rae" <> wrote in message
    news:e%23s$...
    > "Chip Pearson" <> wrote in message
    > news:...
    >
    >> Do Until RecSet.EOF()
    >> Debug.Print RecSet.Fields("Whatever").Value
    >> RecSet.MoveNext
    >> Loop

    >
    > Are you trying to use ADO instead of ADO.NET...?
    >
    > If you're not doing any databinding, I would strongly advise not using any
    > of the DataSource objects at all.
    >
    > Instead, just use ADO.NET to fetch a DataSet from your Jet database...
    > http://www.asp101.com/articles/jay/adodotnet/part3.asp
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
    Chip Pearson, Jul 4, 2007
    #3
  4. "Chip Pearson" <> wrote in message
    news:...

    >>> Do Until RecSet.EOF()
    >>> Debug.Print RecSet.Fields("Whatever").Value
    >>> RecSet.MoveNext
    >>> Loop

    >>
    >> Are you trying to use ADO instead of ADO.NET...?

    >
    > That code was just an example of what I am used to doing (in VB6 and VBA),
    > not what I'm doing now. Yes, I'm using ADO.NET. The link you posted was
    > interesting, but it still relied on binding the data source to a control,
    > in this case the DataGrid. I do NOT want to bind to any control. All I
    > want to do is a FOR loop iterating through the returned records one at a
    > time, examining the various fields of each record.
    >
    > I would be very grateful if you could post some working code that iterates
    > through the result records of a SELECT without (!) binding to any control.


    There are *heaps* of examples of how to do this in MSDN and on Google etc,
    but...

    string strConnectionString = "<...connection string to your Jet
    database...>";
    string strSQL = "<...SELECT * FROM Table WHERE This = That...">;
    using (OleDbConnection objOleDbConnection = new
    OleDbConnection(strConnectionString))
    {
    objOleDbConnection.Open();
    using (OleDbCommand objOleDbCommand = new OleDbCommand(pstrSQL,
    objOleDbConnection))
    {
    using (OleDbDataAdapter objDA = new
    OleDbDataAdapter(objOleDbCommand))
    {
    using (DataSet objDataSet = new DataSet())
    {
    objDA.Fill(objDataSet);
    objOleDbConnection.Close();
    foreach (DataRow objRow in objDataSet.Tables[0].Rows)
    {
    // objRow["Field1"].ToString();
    // objRow["Field2"].ToString();
    // objRow["Field3"].ToString();
    // etc
    }
    }
    }
    }
    }


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
    Mark Rae [MVP], Jul 4, 2007
    #4
  5. Congratulations, Mark! ( Was Re: Unbound Access Data Source )

    Please join me in congratulating Mark Rae, who was just named ASP.NET MVP
    for the excellence and community spirit he has shown in his prolific,
    and technically accurate, answers which have helped hundreds of frequenters
    to the microsoft.public.dotnet.framework.aspnet newsgroup.

    Congratulations, Mark !



    Juan T. Llibre, asp.net MVP
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    ======================================
    "Mark Rae [MVP]" <> wrote
    Juan T. Llibre, Jul 5, 2007
    #5
  6. Re: Congratulations, Mark! ( Was Re: Unbound Access Data Source )

    "Juan T. Llibre" <> wrote in message
    news:%...

    > Congratulations, Mark !


    Aw shucks!

    Gracias, jefe...

    A sus ordines!


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
    Mark Rae [MVP], Jul 5, 2007
    #6
  7. Re: Congratulations, Mark! ( Was Re: Unbound Access Data Source )

    I'll join in the chant. I think Mark is a great addition to the community!

    --
    Regards,
    Alvin Bruney
    ------------------------------------------------------
    Shameless author plug
    Excel Services for .NET is coming...
    https://www.microsoft.com/MSPress/books/10933.aspx
    OWC Black Book www.lulu.com/owc
    Professional VSTO 2005 - Wrox/Wiley


    "Juan T. Llibre" <> wrote in message
    news:%...
    > Please join me in congratulating Mark Rae, who was just named ASP.NET MVP
    > for the excellence and community spirit he has shown in his prolific,
    > and technically accurate, answers which have helped hundreds of
    > frequenters
    > to the microsoft.public.dotnet.framework.aspnet newsgroup.
    >
    > Congratulations, Mark !
    >
    >
    >
    > Juan T. Llibre, asp.net MVP
    > asp.net faq : http://asp.net.do/faq/
    > foros de asp.net, en español : http://asp.net.do/foros/
    > ======================================
    > "Mark Rae [MVP]" <> wrote
    >
    Alvin Bruney [MVP], Jul 5, 2007
    #7
    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. Barry

    Unbound tables or grids of data?

    Barry, Jul 23, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    331
    Barry
    Jul 23, 2003
  2. Barbara Schmidt

    how to get data to unbound control

    Barbara Schmidt, Jun 27, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    416
    Barbara Schmidt
    Jun 27, 2006
  3. Mel
    Replies:
    15
    Views:
    3,189
  4. David C

    Getting unbound ListView data values

    David C, Nov 10, 2009, in forum: ASP .Net
    Replies:
    0
    Views:
    1,189
    David C
    Nov 10, 2009
  5. .NetNewbie

    access textbox values that are unbound in datagrid

    .NetNewbie, Jul 25, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    138
    Elton Wang
    Jul 25, 2005
Loading...

Share This Page