vbscript >> CreateObject("ADODB.Connection") fails

by andreas » Mon, 22 Sep 2003 20:53:13 GMT

Hi,
on my very simple HTML-Site (not an ASP !) I try to connect to a
sql-server:

<html><head>
<SCRIPT LANGUAGE="vbscript">
<!--
Function Test()
dim rst
dim dsn
dim sql
Set rst = CreateObject("ADODB.Recordset")
set dsn = createObject("ADODB.Connection")
dsn.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User
ID=myid;Initial Catalog=Projects;Data Source=SQLServer;pwd=mypass"
sql = "select id, bez from H_Titel"
rst.Open sql, dsn
dim newWindow = window.open("","")
while not (rst.EOF)
newWindow.document.write(rst(0) & " " & rst(1))
newWindow.document.write("<br>")
rst.moveNext
loop
rst.Close
set rst=Nothing
End Function
-->
</SCRIPT>
</head>
<title>VB_Test</title>
<body>
<form name="myForm" action="">
<input type="button" name="but1" value="Klick"
onClick="vbscript:Test()">
</form>
</body>
</html>

When I try to run it, I get en error "a wrong type" (I'm trying to
translate it from german, so I hope it's the same errror message in
english). I suppose there is something wrong with the cration of an
connection object.
SQL Server is running, password and user ID are right, there is no a
network problem. What's wrong?
Andy


vbscript >> CreateObject("ADODB.Connection") fails

by Ray at <%sLocation%> » Mon, 22 Sep 2003 20:57:12 GMT


Have you customized security settings in IE to allow the creation of this
object? (Initialize and script ActiveX controls not marked for safe.) Note
that you do NOT want to do this in the Internet zone. Intranet or trusted
sites only.

Ray at work








vbscript >> CreateObject("ADODB.Connection") fails

by Andy Wawa » Mon, 22 Sep 2003 22:56:12 GMT


Hi Ray,
yes, I customized my IE, but it doesn't work..
Andy


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


CreateObject("ADODB.Connection") fails

by Ray at <%sLocation%> » Mon, 22 Sep 2003 23:01:43 GMT

Try enabling all top five settings in the security settings for the correct
zone. That should work fine. If not, make sure you have MDAC installed on
your machine, which I'm sure you do. Once it's working, go back and put
each setting back to the way it was, until it fails again.

Ray at work







CreateObject("ADODB.Connection") fails

by Walter Zackery » Mon, 22 Sep 2003 23:19:47 GMT

In addition to any security problems that you may have, you have some syntax
errors.

dim newWindow = window.open("","") should be

dim newWindow
Set newWindow = window.open("","")

You also don't have a Wend statement to close your While loop. You should
replace the loop statement that you used with wend.

While...Wend
http://msdn.microsoft.com/library/en-us/script56/html/vsstmwhile.asp
Do http://msdn.microsoft.com/library/en-us/script56/html/vsstmdo.asp
Dim http://msdn.microsoft.com/library/en-us/script56/html/vsstmdim.asp
Window Script Host /VBScript / JScript / Windows Script Component
documentation
http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9&displaylang=en



| Hi,
| on my very simple HTML-Site (not an ASP !) I try to connect to a
| sql-server:
|
| <html><head>
| <SCRIPT LANGUAGE="vbscript">
| <!--
| Function Test()
| dim rst
| dim dsn
| dim sql
| Set rst = CreateObject("ADODB.Recordset")
| set dsn = createObject("ADODB.Connection")
| dsn.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User
| ID=myid;Initial Catalog=Projects;Data Source=SQLServer;pwd=mypass"
| sql = "select id, bez from H_Titel"
| rst.Open sql, dsn
| dim newWindow = window.open("","")
| while not (rst.EOF)
| newWindow.document.write(rst(0) & " " & rst(1))
| newWindow.document.write("<br>")
| rst.moveNext
| loop
| rst.Close
| set rst=Nothing
| End Function
| -->
| </SCRIPT>
| </head>
| <title>VB_Test</title>
| <body>
| <form name="myForm" action="">
| <input type="button" name="but1" value="Klick"
| onClick="vbscript:Test()">
| </form>
| </body>
| </html>
|
| When I try to run it, I get en error "a wrong type" (I'm trying to
| translate it from german, so I hope it's the same errror message in
| english). I suppose there is something wrong with the cration of an
| connection object.
| SQL Server is running, password and user ID are right, there is no a
| network problem. What's wrong?
| Andy




Similar Threads

1. How Do I Do This VB Code In C# - Set Conn = Server.CreateObject("ADODB.Connection")

Set Conn = Server.CreateObject( "ADODB.Connection" )
Conn.Open( "DSN = mydsn; UID = myuserid; PWD = mypassword;" )
sql = "select * from customers"
Set RS = Conn.Execute( sql )

Preferably with a SqlDataAdapter not an OleDbDataAdapter



2. NOT working: Set cn = CreateObject("ADODB.Connection")

3. Method '~' of object '~' failed error while opening ADODB connection in vb6

Hi all,

I am using VB6, MS-Access2000 for my application. The application is
running fine from IDE. But when it is build and run using the
binaries, it is throwing the error "Method '~' of object '~' failed".
When put messages, I found that in the following code, the last line
causing the error.

Dim mcnDBData As ADODB.Connection
Set mcnDBData = New ADODB.Connection
Dim strConnectionString as string
strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:
\Data\Test.mdb;Persist Security Info=False;Jet OLEDB: Database
Password=LFSGenesis;"
Call mcnDBData.Open(strConnectionString)

Can anybody let me know what can cause such an error?

Regards,
Swapna.

4. createobject("adodb.command")

5. Activex Creation Error executing CreateObject("ADODB.Field")

A simple VBScript with the line:

Set oFld = CreateObject("ADODB.Field")

causes an error that the object cannot be created. I've seen various
examples of this so I'm sure it must work. Can anyone tell me why this
wouldn't work? Thanks.

Dan

6. CreateObject failed with VB.Net, but succeded with VB6

7. CreateObject fails AND works

Sorry if this is the wrong group...I THINK I got to the right
place...(oh...and I'm a newbie programmer...so please be gentle)

Anyway I have a program that works fine when I run it from within
VS2005 (no errors and does exactly what it should)

BUT if I build it and then try to run the .exe on the same computer it
fails with:

"Unhandled exception...."

"Cannot create ActiveX component"

It seems to fail on this line:

objAdminSystem = CreateObject("NovellGroupWareAdmin")

I added the reference to this object (Name: Groupwise Admin API
Library)  (Filename: Interop.AdminTypeLibrary.dll)

I did some searching online and found someone had fixed it by running
"regsvr32 gwcmb1.dll"

I tried that (it suceeded) but the program still fails outside of the
VS2005 environment.

Thanks for any help you might be able to provide!

8. CreateObject of VB DLL fails in ASP page