Jump to content

HTA and SQL


dlaw8073

Recommended Posts

Hopefully someone can help, i'm trying to write a HTA application that reads information from an SQL database and then kicks of an unattended build.

However I'm having an issue when attempting to read any values from the SQL database. I have tested with the same code in a VBS file and it executes fine under WinPE 2004.

Code is below:

<HTML>

<HEAD>

<TITLE>HTA - HTML Applications</TITLE>

<HTA:APPLICATION

WINDOWSTATE="maximize"

BORDER="none"

INNERBORDER="no"

SHOWINTASKBAR="no"

SCROLL="no"

APPLICATIONNAME="Build"

NAVIGABLE="yes">

</HEAD>

<script language="VBScript">

Sub TestADO

Set objADOConnection = CreateObject("ADODB.Connection")

Set objRecordSet = CreateObject("ADODB.Recordset")

objADOConnection.Open "Provider=SQLOLEDB;Data Source=MSSQL01;Initial Catalog=BuildDB;User ID=build;Password=build01;"

SQLQuery1 = "Select * From Server"

objRecordSet.Open SQLQuery1, objADOConnection, 2, 2

objRecordSet.MoveFirst

DataArea.InnerHTML = objRecordSet.Fields("ServerName")

End Sub

</script>

<BODY STYLE="font:14 pt arial; color:white; filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr='#000000', EndColorStr='#0000FF')">

<DIV STYLE="position:relative;left:90;top:100;width:100%;">

<FONT COLOR="White" FACE="Tahoma">

<H2>Build Environment </H2>

<BR><BR>

<INPUT TYPE="button" VALUE="ADO Test" NAME="run_button" onClick="TestADO">

<P>

<BUTTON ACCESSKEY="x" STYLE="font-face:Tahoma;font-size:13px;" onClick="self.close()">E<U>x</U>it</BUTTON>

<SPAN ID = "DataArea"></SPAN>

</FONT>

</DIV>

</BODY>

</HTML>

When I click the ADO Test button nothing happens. As mentioned if i create a VBS file with the VBScript code for the sub TestADO it works fine (using wscript.echo).

It seems to fail on objADOConnection.Open line, found this out by commentting out each line in turn.

Any ideas?

Edited by dlaw8073
Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...