Problems Internet Information Service (IIS) Datagrid or table

Posted on 2005-04-22
Last Modified: 2010-05-18
Hie Guys

I want to display data in an access database table on a data grid to be presented in an IIS Application. L also want each row on that datagrid to link to a different page.

Looking forward to your assistance

Question by:nyathim
    1 Comment
    LVL 2

    Accepted Solution

    1. Create a new Web App in VB.NET

    2. Drop a button and a datagrid on the form

    3. In this example I have a Microsoft Access database called EE2.MDB with a table called EMPLOYEE.  The table has two fields, an EMP_NAME and an EMP_WEBSITE.  You will need to substitute your own database information in the following code.

    4. Paste this code

        Private Sub FillDataGrid()
            Dim oledb_Cn As Data.OleDb.OleDbConnection
            Dim oledb_Da As Data.OleDb.OleDbDataAdapter
            Dim sCn As String
            Dim dsDataSet As New DataSet
            Dim sSQL As String

                'create a connection string
                sCn = ""
                sCn = sCn & "Provider=Microsoft.Jet.OLEDB.4.0;"
                sCn = sCn & "Data Source=C:\EE2.MDB;"
                sCn = sCn & "Persist Security Info=False"

                'create a SQL string
                sSQL = "SELECT * FROM EMPLOYEE "

                'create oledb objects
                oledb_Cn = New Data.OleDb.OleDbConnection(sCn)
                oledb_Da = New Data.OleDb.OleDbDataAdapter(sSQL, oledb_Cn)

                'fill the dataset
                oledb_Da.Fill(dsDataSet, "EMPLOYEE ")

                'bind the grid
                DataGrid2.DataSource = dsDataSet.Tables("EMPLOYEE ").DefaultView

            Catch ex As Exception
                '"Data error encountered: " & ex.Message.ToString
            End Try

        End Sub

    5. Make the above code work with your database: Change C:\EE2.MDB in on place in the above code.  Change the SQL statement.  And change the table name EMPLOYEE in two places.

    6. Make your button run the code, and test it to make sure it is showing the data in the grid (the hyperlinks won't be there yet.)

    7. If you have a field in your database that contains URLs, you get them to show as  hyperlinks by right clicking your DataGrid in the design window, and selecting "Property Builder..."  On the left, click the second item down called "COLUMNS".  In the Available Columns list, select HYPERLINK COLUMN and push the button with the > sign to put it into the selected columns list.  Then configure your new hyperlink column by filling in the TEXT FIELD and the URL FIELD boxes.  

    The URL field is the name of the database field that holds the actual web site URLs.  The TEXT field is for the database field that shows what you want the link to say.  For example, I wanted it to show the name BOB and when the user clicks his name it it goes to bob's favorite search engine.  So in the TEXT FIELD I typed EMP_NAME and in the URL FIELD I typed EMP_WEBSITE.  You will simply need to substitute your database field names approriately.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Suggested Solutions

    INTRODUCTION We all know how to code. But at times you simply want to insert a common code block into your existing code and amend it as per your requirements. This tool not only saves you time but also saves you the pain of typing it all out aga…
    This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now