Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / JScript / April 2005

Tip: Looking for answers? Try searching our database.

Use JavaScript or Jscript to connect SQL2000, posible?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
WTS - 20 Apr 2005 10:18 GMT
Hit there,

I am searching hi and lo for the above mentioned. Is it posible to do? If
so, how?
I want to use this script at my aspx page.

Thanks in advance.

WTS
Bruce Barker - 20 Apr 2005 17:08 GMT
yes.

1) with javascript, use the ado com classes
2) with jscript.net use SqlClient classes

-- bruce (sqlwork.com)

> Hit there,
>
[quoted text clipped - 5 lines]
>
> WTS
WTS - 21 Apr 2005 15:13 GMT
Thanks for your tip, Bruce.

Is there any sample code for JScript to connect SQL?

Regards

WTS

> yes.
>
[quoted text clipped - 12 lines]
> >
> > WTS
Serge Baltic - 21 Apr 2005 16:03 GMT
W> Is there any sample code for JScript to connect SQL?

Both mentioned technologies (ADO and SqlClient) are language-independent
and can be used from ANY language you like in the same way. Just use any
example and change its syntax a bit to fit JScript specs. Thus no much need
for such samples.

(H) Serge
WTS - 22 Apr 2005 03:34 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.