Thank you, Joe, for you posting. Discussion in this thread was very useful.
I'm also strugling with sqlServer<->htmlClient issue and close to loose hope to solve it. You might give some light what is wrong.
My MSSQL seats on one server and IIS on another.
Straight ASP page works fine across "real" web.
My goal is to bring records to html drop-down list so user can drill the same database later. Its part of frames set and it is not easy to change whole existing design.
Got an Object expected trying to bring records from ASP to client side. As I understand your suggestion it should be easy to do.
This is dbTest.htm:
-----------------------------------
<SCRIPT LANGUAGE="JavaScript" src="readDb.asp" runat="server"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" runat="server">
var names = new Array();
names = readDb(); // Object expected
//names = parent.MyFrame.readDb(); // Object doesn't support this property or method
</SCRIPT>
<HTML>
<HEAD>
<TITLE>DB Test</TITLE>
</HEAD>
<BODY BGCOLOR="#000033">
<SCRIPT LANGUAGE="JavaScript">
document.writeln('Communities');
document.writeln('<select name="quickZoom" size="10">');
document.writeln('<option selected value="-">zoom to...');
for ( j = 0; j < names.length; j++ ) {
document.writeln('<option value="'+names[j]+ '">' + names[j]);
}
document.writeln('</select>');
</SCRIPT>
</BODY>
</HTML>
And this is DB reader readDb.asp:
-----------------------------------
<SCRIPT LANGUAGE="JavaScript" runat="server">
function readDb() {
var conn = Server.CreateObject("ADODB.Connection");
var strConn = "Provider=SQLOLEDB.1;Data source=amsql;Database=asdi;Trusted_Connection=yes; User ID=guest;Password=password;"
conn.Open(strConn);
var rs = conn.Execute("SELECT * FROM TBLCOMMUNITIES");
var j = 0;
var names = new Array();
while (!rs.EOF)
{
names[j++] = rs("name");
rs.MoveNext();
}
rs.Close();
conn.Close();
return names;
}
</SCRIPT>
[/code]
Could you tell if it is possible at all?
Happy programming!
Quote:
quote:Originally posted by joefawcett
If you want to create a client-side connection object then use
Code:
var conn = new ActiveXObject("ADODB.Connection");
However the remaining code won't run unless you have both lowered the browser's security settings to allow local file access and have a database at the c:\inetpub... location.
--
Joe (Microsoft MVP - XML)
|