Solved

JavaScript Connection String

Posted on 2002-07-04
15
364 Views
Last Modified: 2008-01-16
I can do the Dns-less Connection String with vbScript but I call myself JScripter so I would like to Code my ASP with JavaScript. Please help me out, Provide me usefull links so I could convert my asp/vb Skills to asp/JScript. Most Important to me is Connection String right now. Because I believe Asp use same objects for both Languages:-). Covert this to JScript..
set con = Server.Createobject("ADODB.CONNECTION")
con.open "Driver = {Microsoft Access Driver (*.mdb)}; DBQ = "& server.mappath("mydatabase.mdb")

This was in Vb please Provide me the code for JavaScript.
0
Comment
Question by:adilkhan
  • 6
  • 2
  • 2
  • +2
15 Comments
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 7131258
What is the difference if you convert the connectionstring above to Javascript? bcos what important is you still need those connectionstring to connection to the database via ASP.

JScript/Javascript cannot connection to database.

Intead you may create different connectionstring for each data connection, if the result didn't works.

regards
0
 
LVL 9

Expert Comment

by:AlfaNoMore
ID: 7131474
You're absolutley right, the ASP.dll uses the same five objects in both languages (Server, Response. Request, Session, Application, [oh, and Error]).

So your conversion would be:

<%@Language="JScript" %>

<%

var con = Server.CreateObject('ADODB.CONNECTION');
con.Open('Driver = {Microsoft Access Driver (*.mdb)}; DBQ = ' + Server.MapPath('mydatabase.mdb');

%>

Bear in mind that JScript is case sensitive, whereas VBscript isn't. So when things don't work, could just be that you've missed out a capital letter somewhere!!!
0
 
LVL 23

Author Comment

by:adilkhan
ID: 7132382
Responding to ryancys: It does matter if a user wants to use JScript or VbScript. Because few peoples  like to use Loops in JScript and few people are comfortable with VbScript. Asp will just give you few objects to interact with the database, but its CLient Side Language  will help you to do things.
Now Back to question, AlpaNoMORE I tried the code you gave me but unfortunately its not working here is the exact code I typed for my connection String.
<%@Language="JScript"%>
<%

var con = Server.CreateObject('ADODB.CONNECTION');
con.Open('Driver = {Microsoft Access Driver (*.mdb)}; DBQ = ' + Server.MapPath('profile.mdb');
%>

and here is the Error I Receieved :
Error Type:
Microsoft JScript compilation (0x800A03EE)
Expected ')'
/dma/query/java1.asp, line 5, column 93
con.Open('Driver = {Microsoft Access Driver (*.mdb)}; DBQ = ' + Server.MapPath('profile.mdb');


I hope you can figure it out.
Thanks.
0
 
LVL 39

Expert Comment

by:appari
ID: 7133120
seems missing closing paranthasis

con.Open('Driver = {Microsoft Access Driver (*.mdb)}; DBQ = ' + Server.MapPath('profile.mdb');

change to

con.Open('Driver = {Microsoft Access Driver (*.mdb)}; DBQ = ' + Server.MapPath('profile.mdb'));
0
 
LVL 23

Author Comment

by:adilkhan
ID: 7133226
Still no Luck. Now its giving me the General Database not found error. Any CLue why? I am sure about the Database Location(because its working with the VbScript)
0
 
LVL 23

Author Comment

by:adilkhan
ID: 7179177
I am still looking forward for the Correct Answer.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 39

Accepted Solution

by:
appari earned 50 total points
ID: 7200848
adilkhan:
check this link, http://www.webreference.com/js/column55/index.html
try var con = new ActiveXObject("ADODB.CONNECTION");
0
 
LVL 58

Expert Comment

by:Gary
ID: 8845192
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
PAQ'd and pts forfeited
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
GaryC123
EE Cleanup Volunteer
0
 
LVL 23

Author Comment

by:adilkhan
ID: 8846192
I did not get the Right Answer. I am still unable to connect via jScript.
0
 
LVL 58

Expert Comment

by:Gary
ID: 8846311
Coding this in Javascript is just making a hard work of an easy job.  You obviously can use ASP so I don't understand why you need to use javascript to do it.  Anyone that doesn't have a javascript enabled broswer or has javascript disabled will find your site useless.  And if I remember correctly this only really works in IE

This is a Jscript example
http://www.aspemporium.com/aspEmporium/src/js_srcview.asp?source=database_read.asp
0
 
LVL 23

Author Comment

by:adilkhan
ID: 8849948
Gary i am Talking about SERVER SIDE jScript here not CLIENT SIDE.
Server Side JSCRIPT is available to all Audience same as VBSCRIPTwe use with ASP.
0
 
LVL 23

Author Comment

by:adilkhan
ID: 9270033
Finaly I got the Solution.
Should I accpet an Answer or you guys Would like to Close it?
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now