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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with ADODB.Connection error, Automation server can't create object

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
US
Unhandled exception at line 103, column 5 in 0x800a01ad - JavaScript runtime error: Automation server can't create object.

on yellow highlight. This is an issue now with IE 10. IE 10 blocks the ADODB as a threat. Need another way to open a SQL connection other than ADODB.
This ccode draws rectangles on a canvas. I can have the X-Y [highlight #8AE234]coords[/highlight] in an XML file or other file if need be, SQL is best though.
TIA
Code:
<script>

    var c = document.getElementById("myCanvas");
    c.width = window.screen.availWidth
    c.height = window.screen.availHeight
    var ctx = c.getContext("2d");
    ctx.fillStyle = "#FF0000";
    //ctx.fillRect(55, 35, 150, 75);

    [highlight #FCE94F]var connection = new ActiveXObject("ADODB.Connection");[/highlight]    var connectionstring = "Data Source=myserver;Initial Catalog=myCatalog;Persist Security Info=True;User ID=userID;pwd=Password;Provider=SQLOLEDB";

    connection.Open(connectionstring);
    var rs = new ActiveXObject("ADODB.Recordset");

    rs.Open("Select [highlight #8AE234]TopLocation, LeftLocation, Width , Height[/highlight] [highlight #8AE234][/highlight]from grocery_StoresXYAisles", connection);
    rs.MoveFirst
    while (!rs.eof) {
        //document.write(rs.fields(1) + " " + rs.fields(0) + " " + rs.fields(2) + " " + rs.fields(3) + "\r\n");
        ctx.fillRect(rs.fields(1), rs.fields(0), rs.fields(2), rs.fields(3));
        rs.movenext;
   }

    rs.close;
    //connection.close;
    c.fillStyle = "blue";
    c.font = "bold 16px Arial";
    c.fillText("Zibri", 100, 100);

</script>

DougP
 
are you intending the connection to be opened over the web? or is this intended to be a server-side script only (i assume the former since you mentioned IE 10)

if over the web, are you:

1. sure it should work? you will need to enable the relevant insecure access rights, and ports etc on your server
2. i would have thought you'd need at least to specify the Remote.x parameters and/or the url in the connection string, even though I note that you say the code is failing at an earlier point. I guess it may depend on the versions you are using
3. sanguine that this is very far from good practice in a web environment?
4. sanguine that this may introduce security vulnerabilities?
5. sanguine that this restricts your consumer base to those that use only MS browsers and have set their browsers to a low-security environment?

have you tried capturing the exception and seeing what it says? that might give you a clue as to the source of the error ...

Code:
if (window.ActiveXObject) {
    try {
        var connection = new ActiveXObject ("ADODB:Connection");
        var connectionstring = "Data Source=myserver;Initial Catalog=myCatalog;Persist Security Info=True;User ID=userID;pwd=Password;Provider=SQLOLEDB";
        connection.Open(connectionstring);
     } catch (e) {
        alert(e.message);
    }
} else {
    alert ("Your browser does not support creating a database connection.");
}

the better way to achieve this is via ajax. an ajax connection is simplicity itself to create from javascript. the server side coordinates lookup is easy to achieve and secure and you spit the data back to the browser using json. the whole solution would take less time that it took me to write this post!

of course, your code, your issues so if you want to stick with a remote database lookup then we can try and work it through with you.

question: how large (in number of records) is this dataset?
 
jpadie's, thanks then how about a code snippet in Ajax to get me started. Remember this needs to go in an HTML 5 canvas or other container.


DougP
 
sure. would be a pleasure.

can you give me an idea of the structure of the database? for my purposes the only relevance is the top and left coords and I can see those field names from your post, but I cannot see WHERE clause aspect to know what information to send,

 
I am creating a warehouse map and at some point I want to pinpoint a location of where a specific aisle is on that map with a small dot. So all of the Asile coordinates will be in the database. The original code loops through each record drawing an aisle on the Canvas.
There are just 7 columns:
UniqueID int
[highlight #AD7FA8]Aisle[/highlight] nvarchar(20)
Storename nvarchar(100)
[highlight #FCE94F]TopLocation[/highlight] int,
[highlight #FCE94F]LeftLocation[/highlight] int,
[highlight #FCE94F]Width[/highlight] int,
[highlight #FCE94F]Height[/highlight] int

so this is going to draw all the [highlight #FCE94F]Aisles[/highlight] and label them too, below the [highlight #AD7FA8]Aisle[/highlight] drawn.

TIA

DougP
 
ok. I will post an end-to-end solution for you (as a proof of concept for you to build on) later tonight unless you are more pressed for time than that?

 
how do you derive from the table what the bottom right hand coordinate of the map is?
 
I don't care , yet. the canvas side I guess. make it anything. 1000, 1000 if you need a number. I just need to get a data connection other than ADODB. used it for years in everything but now it seems its a security threat. Or Big "Mic" just decides a change is in order. things have gone downhill since Bill Gates left.

DougP
 
it's a security threat to use ADODB client side. but also it's a major limitation as only IE clients can use it. so why would any web-developer use that?

if your code only runs server side then the activex object is not a threat. but why bother using activex if you are using aspx. just create a native ADO connection.

ok - i will stub out the bottom, right coordinates with dummy data for the time being. obviously correct data is necessary for a correct result though.

i now need access to the data that associates the product with the coordinates. can you send me the data dump for the three sites that you have currently? you can find my email address on my publishing site at rathercurious.net. the data is needed for testing purposes. i have a database of products and aisles by store already. but not their location coordinates
 
All I really need is the connection code to replace this. If ADO is bad then please give me a snippet to replace it. I don't understand very much. and I program based on examples.
Code:
var connection = new ActiveXObject("ADODB.Connection");  

 var connectionstring = "Data Source=myserver;Initial Catalog=myCatalog;Persist Security Info=True;User ID=userID;pwd=Password;Provider=SQLOLEDB";

    connection.Open(connectionstring);
    var rs = new ActiveXObject("ADODB.Recordset");
and code to loop through as above.

DougP
 
doug,
you're not answering my implied questions so i have no idea what code to give you to replace that.

is it server side code?
is it client side code?

what i have done is:

1. built a client side solution to query your server-side database to retrieve products and coordinates
2. show the products on the client side
3. allow the client-side to map the products directly on to the blueprint.
4. built a server-side api to serve the coordinate and product data to the client via json.

to finish what i have done, I need the coordinate database to test against. if you are unwilling to provide that then i can mock up a dataset, but that will take time.

if you are not interested in the above, then I have misunderstood your request (and it seems that I have). and to help further I would need you to give precise answers to the earlier questions.

 
here is a sample. I don't have anything data yet. when I can connect to the Server side datbase without error, I will then proceed with figuring out the rest.

Code:
Storename	Aisle	TopLocation	LeftLocation	 Width	Height
Store123	A1A	50	160	20	160
Store123	A2A	50	190	20	160
Store123	A3A	50	220	20	160
Store123	A4A	50	250	20	160
Store123	A5A	50	280	20	160
Store123	A6A	50	310	20	160

DougP
 
are you saying that you cannot connect server-side using server side code?

if so, what have you tried so far (the above code being client side, one assumes)?

 
No I have no idea. I done. Outta here

DougP
 
no idea why you've given up. (I'm assuming that you understand the terminology 'client-side' and 'server-side').

anyway - an example of how ajax is used by a client to get data from a server side database is posted in your other thread. as said, it's very simple.

other thread:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top