Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with VB DHTML

Status
Not open for further replies.

pcawdron

Programmer
Jun 14, 2000
109
AU
Hi,

The following works in VB, but not in VB's DHTML...

Dim WithEvents R As ADODB.Recordset
Dim cn As New ADODB.Connection

Private Sub DHTMLPage_Load()
cn.Open "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=C:\Test.mdb"
Set R = New Recordset
R.Open "SELECT * FROM [Test]", cn, adOpenStatic, adLockOptimistic
Set Grid.DataSource = R
End Sub

It loads a datagrid on a form in VB6, but I can't get it to load a datagrid in DHTML. (The ADO Recordset is fine in both)

Can anyone tell me why?

Or, can anyone tell me how I can load a datagrid from a database?

Thanks,
Peter
 
The MS Datagrid requires licencing. Use the licence package tool (found on the VB cd) to create a .lpk file. Before creating any other active-x objects you should refer to this file using the following code in your html:

Code:
<OBJECT classid=clsid:5220cb21-c88d-11cf-b347-00aa00a28331 VIEWASTEXT>
<PARAM NAME=&quot;LPKPath&quot; VALUE=&quot;yourfile.lpk&quot;>
</OBJECT>

The guid is the same for every version of ie.

Jordi Reineman
 
Thanks Jordi,

I'm a novice with HTML.

I can now get my HTML page to show the datagrid control on the page but the code still doesn't work. I'm asuming LPKPath in your answer is the path of the file yourfile.lpk in your answer.

I ran the licence package tool and made a .lpk file

I've taken a blank HTML page that says 'hello' and inserted both the Object clause you gave me above with the correct path and file names and a Datagrid object (As built by VB's DHTML editor) and the VB routine above (enclosed in the <BODY> section by <Script language='vbscript'></script> but it brings up an empty Datagrid.

Thanks for your help.
 
Hi pcawdron,

LPKPath is the name of the parameter and shouldn't be changed. When IE launches the Licence manager (implemented by the guid) it looks for this namedparameter, obviously when you've changed it's name it cannot find it. The 'value' property applies to the (relative) path of the .lpk file.

This could be the first part of your problem. Secondly, you can't create objects in dhtml like you do in vb. IE must first create a design-time recordset with the <object> tag.

Furthermore as far as I know you can't add a datagrid directly to dhtml, you will have to create an axtive-x control in VB first or use the grid control, which is avaiable to dhtml.

If you have the MSDN cd look for dhtml and then on 'using for data access' or look on the msdn site msdn.microsoft.com

Good luck!

Jordi Reineman
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top