Thanks Serge,
I did try earlier to interprete it into jscript, but it return error as
"Server" is undefined".
my code example
<script language="jscript">
function try()
{
var myCon = Server.CreateObject("ADODB.Connection");
...
}
</script>
> W> Is there any sample code for JScript to connect SQL?
>
[quoted text clipped - 4 lines]
>
> (H) Serge
Serge Baltic - 22 Apr 2005 12:09 GMT
W> I did try earlier to interprete it into jscript, but it return error
W> as "Server" is undefined".
W> <script language="jscript">
Seems like you're trying to write this in client-side script instead of server-side.
So it gets executed in the user's browser — and there's no server in it,
definitely.
For an aspx page, write the code either in the codebehind class, or in a
<script runat="server"> tag, or in between the <% and %> tags, to get it
executed on the server.
Also, Server.CreateObject seems to me to be come legacy of non-.NET-ASP (not
aspX), which helped it to deal with apartments and object lifetime. In JScript.NET
you could use "new ActiveXObject(…)" instead. But that's my IMHO and may
have some impact on server work. Either way, will be OK for a startup sample,
I think.
PS check the "C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\QuickStart\howto\samples"
or similar, if you've gotten Visual Studio or .NET SDK — there are samples
for what you're trying to do. Sometimes in JS too.
(H) Serge
Bruce Barker - 23 Apr 2005 00:51 GMT
the Server object is only supported by classic asp. what enviroment are you
using (wsh, browser, asp, asp.net?). if you are using the browser, then you
will not have permission to create the objects unless the site is trusted.
try:
var myCon = new ActiveXObject("ADODB.Connection");
-- bruce (sqlwork.com)
> Thanks Serge,
>
[quoted text clipped - 19 lines]
>>
>> (H) Serge
WTS - 23 Apr 2005 04:15 GMT
Hi Bruce & Serge,
Thanks for all your tips. I finally got it and everything works beautifully!
Best reagards to you.
WTS
> the Server object is only supported by classic asp. what enviroment are you
> using (wsh, browser, asp, asp.net?). if you are using the browser, then you
[quoted text clipped - 29 lines]
> >>
> >> (H) Serge