K
kederstedt
Hi
Can someone explain to me why I can run one VBS file and one HTA file
on my local computer (windows XP pro), but on another computer (Windows
PE) the HTA file fails. The HTA file just stops and I get no error
message, but the error is when I create the SQL connection object and
the recordset object. Both scripts contains SQL connection to
Northwind. I made a simple HTA file with just one MessageBox and that
file worked fine.
You can see both my scripts below
------- VBS -------
' Declare the variables
Dim objConn
Dim objRst
Dim strSQL
Dim strServer
Dim strDatabase
Dim strUserName
Dim strPassword
Dim strDisplay
' Set server, database and username
strServer = "MyComputer"
strDatabase = "Northwind"
strUserName = "sa"
strPassword = "password123"
'Create and open the database object
set objConn = CreateObject("ADODB.Connection")
set objRst = CreateObject("ADODB.Recordset")
strSQL ="SELECT FirstName, LastName FROM Employees "
objConn.open "Provider=SQLOLEDB;Data Source=" & strServer & ";Initial
Catalog=" & strDatabase & ";User ID=" & strUserName & ";Password=" &
strPassword & ";"
Set GetRst = objConn.Execute(strSQL)
If Not GetRst.EOF Then
strDisplay = "Users from the Employees table: " & vbcrlf & vbcrlf
Do While Not GetRst.EOF
strDisplay=strDisplay & GetRst("FirstName") & " " &
GetRst("LastName") & vbcrlf
GetRst.MoveNext
Loop
MsgBox strDisplay
Else
MsgBox "No data in Recordset"
End If
------- END VBS -------
-------- HTA --------
<HTA:APPLICATION ID="oBDDID"
APPLICATIONNAME="BDDIB"
BORDER="thin"
CAPTION="yes"
ICON="oemlogo.jpg"
SCROLL="auto"
SHOWINTASKBAR="yes"
SINGLEINSTANCE="yes"
SYSMENU="yes"
WINDOWSTATE="normal" />
</head>
<script language="vbscript">
' Declare the variables
Dim objConn
Dim objRst
Dim strSQL
Dim strServer
Dim strDatabase
Dim strUserName
Dim strPassword
Dim strDisplay
' Set server, database and username
strServer = "MyComputer"
strDatabase = "Northwind"
strUserName = "sa"
strPassword = "password123"
'Create and open the database object
set objConn = CreateObject("ADODB.Connection")
set objRst = CreateObject("ADODB.Recordset")
strSQL ="SELECT FirstName, LastName FROM Employees "
objConn.open "Provider=SQLOLEDB;Data Source=" & strServer & ";Initial
Catalog=" & strDatabase & ";User ID=" & strUserName & ";Password=" &
strPassword & ";"
Set GetRst = objConn.Execute(strSQL)
If Not GetRst.EOF Then
strDisplay = "Users from the Employees table: " & vbcrlf & vbcrlf
Do While Not GetRst.EOF
strDisplay=strDisplay & GetRst("FirstName") & " " &
GetRst("LastName") & vbcrlf
GetRst.MoveNext
Loop
msgbox strDisplay
Else
msgbox "No data in Recordset"
End If
</script>
------- END HTA -------
Can someone explain to me why I can run one VBS file and one HTA file
on my local computer (windows XP pro), but on another computer (Windows
PE) the HTA file fails. The HTA file just stops and I get no error
message, but the error is when I create the SQL connection object and
the recordset object. Both scripts contains SQL connection to
Northwind. I made a simple HTA file with just one MessageBox and that
file worked fine.
You can see both my scripts below
------- VBS -------
' Declare the variables
Dim objConn
Dim objRst
Dim strSQL
Dim strServer
Dim strDatabase
Dim strUserName
Dim strPassword
Dim strDisplay
' Set server, database and username
strServer = "MyComputer"
strDatabase = "Northwind"
strUserName = "sa"
strPassword = "password123"
'Create and open the database object
set objConn = CreateObject("ADODB.Connection")
set objRst = CreateObject("ADODB.Recordset")
strSQL ="SELECT FirstName, LastName FROM Employees "
objConn.open "Provider=SQLOLEDB;Data Source=" & strServer & ";Initial
Catalog=" & strDatabase & ";User ID=" & strUserName & ";Password=" &
strPassword & ";"
Set GetRst = objConn.Execute(strSQL)
If Not GetRst.EOF Then
strDisplay = "Users from the Employees table: " & vbcrlf & vbcrlf
Do While Not GetRst.EOF
strDisplay=strDisplay & GetRst("FirstName") & " " &
GetRst("LastName") & vbcrlf
GetRst.MoveNext
Loop
MsgBox strDisplay
Else
MsgBox "No data in Recordset"
End If
------- END VBS -------
-------- HTA --------
<HTA:APPLICATION ID="oBDDID"
APPLICATIONNAME="BDDIB"
BORDER="thin"
CAPTION="yes"
ICON="oemlogo.jpg"
SCROLL="auto"
SHOWINTASKBAR="yes"
SINGLEINSTANCE="yes"
SYSMENU="yes"
WINDOWSTATE="normal" />
</head>
<script language="vbscript">
' Declare the variables
Dim objConn
Dim objRst
Dim strSQL
Dim strServer
Dim strDatabase
Dim strUserName
Dim strPassword
Dim strDisplay
' Set server, database and username
strServer = "MyComputer"
strDatabase = "Northwind"
strUserName = "sa"
strPassword = "password123"
'Create and open the database object
set objConn = CreateObject("ADODB.Connection")
set objRst = CreateObject("ADODB.Recordset")
strSQL ="SELECT FirstName, LastName FROM Employees "
objConn.open "Provider=SQLOLEDB;Data Source=" & strServer & ";Initial
Catalog=" & strDatabase & ";User ID=" & strUserName & ";Password=" &
strPassword & ";"
Set GetRst = objConn.Execute(strSQL)
If Not GetRst.EOF Then
strDisplay = "Users from the Employees table: " & vbcrlf & vbcrlf
Do While Not GetRst.EOF
strDisplay=strDisplay & GetRst("FirstName") & " " &
GetRst("LastName") & vbcrlf
GetRst.MoveNext
Loop
msgbox strDisplay
Else
msgbox "No data in Recordset"
End If
</script>
------- END HTA -------