[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How does one create a dynamic Table or Grid using DHTML (VB)

Posted on 2004-11-05
4
Medium Priority
?
211 Views
Last Modified: 2010-05-02
Hi

I have created a simple DHMTL Project within VB6. The DHTML Pages communicate with SQL Stored Procedures.

I know how to get the DHMTL Pages to communicate with my database, but I don’t know how to create a dynamic table or grid.

I would like the following:
- I want to create a function (within VB's DHTML) which creates a table or grid dynamically on my page.
- The table or grid will be generated from any stored procedure or record set I choose.
- I will require the capability of sorting on the columns (when clicking a column header)
- I also want to be able to read a value (from one of the columns) in the selected row (selected by user).

If anyone could provide some examples of how to do the following I would be extremely greatful. You could also recieve 500 points as a token of my appreciation.

Thanks
0
Comment
Question by:abbeygroup
  • 4
4 Comments
 
LVL 7

Expert Comment

by:wesbird
ID: 12503644
See:

http://msdn.microsoft.com/library/default.asp?url=/workshop/author/tables/buildtables.asp

"innerText and innerHTML properties of the table and tr objects are read-only."

Unfortunately it's not possible to replace the innerHTML of tables so you'll have to regenerate the table by adding and removing rows - or replacing the entire table.  The link above should help you and clarify this.
0
 
LVL 7

Expert Comment

by:wesbird
ID: 12503714
0
 
LVL 7

Expert Comment

by:wesbird
ID: 12510071
You'll need something like this:

Private Sub DHTMLPage_Load()
    Dim cnn As New ADODB.connection
    Dim cmd As New ADODB.Command
    Dim rs As ADODB.Recordset
    Dim strHTML As String
    Dim j As Integer
   
    Dim strRS As String
   
    cnn.open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
           "Data Source=C:\Program Files\Microsoft Office\Office\Samples\northwind.mdb;" & _
           "User Id=admin;" & _
           "Password="

    cmd.ActiveConnection = cnn
    cmd.CommandText = "SELECT * FROM Customers"
    Set rs = cmd.Execute
   
    strHTML = "<table id='test' class='sortable'>"
    If Not rs.EOF And Not rs.BOF Then
        rs.MoveFirst
       
        strHTML = strHTML & "<tr>"
        For j = 0 To rs.Fields.Count - 1
            strRS = CStr(rs(j).Name)
            strHTML = strHTML & "<th>" & strRS & "</th>"
        Next
        strHTML = strHTML & "</tr>"
       
        While Not rs.EOF And Not rs.BOF
            strHTML = strHTML & "<tr>"
            For j = 0 To rs.Fields.Count - 1
                If IsNull(rs(j)) Then
                    strRS = "<NULL>"
                Else
                    strRS = CStr(rs(j))
                End If
                strHTML = strHTML & "<td>" & strRS & "</td>"
            Next
            strHTML = strHTML & "</tr>"
           
            rs.MoveNext
        Wend
    End If
    strHTML = strHTML & "</table>"
   
    DHTMLPage.Document.body.innerHTML = strHTML
   
End Sub

Still trying to figure out the sortable columns though.  You may have to transcript the Javascript to VB?

Wes


0
 
LVL 7

Accepted Solution

by:
wesbird earned 1500 total points
ID: 12510173
One very important thing to note here is that with WinXP SP2 you get a popup blocker message every time you try to debug the code.  Serious investigation of network policies is requred if this is for a commercial app.  You'd be much better off using a Webclass on an ASP server, which also would sort out the Javascript integration problem too.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

873 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