Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 15th, 2006, 07:31 AM
Registered User
Join Date: May 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Bind datagrid to recordset

Hi is there a way to encorporate the following working code into the datagrid example? thank you....

If strSearch <> "" Then
    ' MapPath of virtual database file path to a physical path.
    ' If you want you could hard code a physical path here.
        strDBPath = Server.MapPath("Contacts.mdb")

        ' Create an ADO Connection to connect to the sample database using OLE DB.
        cnnSearch = Server.CreateObject("ADODB.Connection")

    ' This line is for the Access sample database:
        cnnSearch.Open("Provider=Microsoft.Jet.OLEDB.4.0;D ata Source=" & strDBPath & ";")

        ' Build our query based on the input.
        strSQL = "SELECT * " _
         & "FROM [tblEmployee] " _
         & "WHERE Name LIKE '%" & Replace(strSearch, "'", "''") & "%' " _
         & "ORDER BY Name;"

        ' Execute our query using the connection object. It automatically
        ' creates and returns a recordset which we store in our variable.
        rstSearch = cnnSearch.Execute(strSQL)

        ' Display a table of the data in the recordset. We loop through the
        ' recordset displaying the fields from the table and using MoveNext
        ' to increment to the next record.

<table border="1">

    Do While Not rstSearch.EOF

        <td><%= rstSearch.Fields("Name").Value %> </td>




    ' Close our recordset and connection and dispose of the objects
        rstSearch = Nothing
        cnnSearch = Nothing
End If


<asp:GridView ID="GridView1" runat="server" CellPadding="2"
          ForeColor="#333333" GridLines="None" BorderStyle="None" CellSpacing="2" HorizontalAlign="Center" Width="850px">

            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" Wrap="False" />
            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" Wrap="False" />
            <EditRowStyle BackColor="#999999" Wrap="False" />
            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" HorizontalAlign="Center" Wrap="False" />
            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <AlternatingRowStyle BackColor="White" ForeColor="#284775" Wrap="False" />


Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to bind Recordset to an Access Subform in VB? fcortes BOOK: Access 2003 VBA Programmer's Reference 1 March 1st, 2008 08:39 PM
bind recordset to field ibgreen SQL Language 0 October 24th, 2006 12:48 PM
How to bind data from a recordset to a combobox? wayne62682 Access VBA 6 April 2nd, 2006 08:45 PM
Bind image to the datagrid learner_7983 ADO.NET 3 November 1st, 2004 02:00 AM
How to bind text box to recordset fields? cici VB How-To 2 December 1st, 2003 02:10 AM

All times are GMT -4. The time now is 02:51 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.