Saqib Khan
asked on
JavaScript Connection String
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 .CONNECTIO N")
con.open "Driver = {Microsoft Access Driver (*.mdb)}; DBQ = "& server.mappath("mydatabase .mdb")
This was in Vb please Provide me the code for JavaScript.
set con = Server.Createobject("ADODB
con.open "Driver = {Microsoft Access Driver (*.mdb)}; DBQ = "& server.mappath("mydatabase
This was in Vb please Provide me the code for JavaScript.
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 .CONNECTIO N');
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!!!
So your conversion would be:
<%@Language="JScript" %>
<%
var con = Server.CreateObject('ADODB
con.Open('Driver = {Microsoft Access Driver (*.mdb)}; DBQ = ' + Server.MapPath('mydatabase
%>
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!!!
ASKER
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 .CONNECTIO N');
con.Open('Driver = {Microsoft Access Driver (*.mdb)}; DBQ = ' + Server.MapPath('profile.md b');
%>
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.md b');
I hope you can figure it out.
Thanks.
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
con.Open('Driver = {Microsoft Access Driver (*.mdb)}; DBQ = ' + Server.MapPath('profile.md
%>
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.md
I hope you can figure it out.
Thanks.
seems missing closing paranthasis
con.Open('Driver = {Microsoft Access Driver (*.mdb)}; DBQ = ' + Server.MapPath('profile.md b');
change to
con.Open('Driver = {Microsoft Access Driver (*.mdb)}; DBQ = ' + Server.MapPath('profile.md b'));
con.Open('Driver = {Microsoft Access Driver (*.mdb)}; DBQ = ' + Server.MapPath('profile.md
change to
con.Open('Driver = {Microsoft Access Driver (*.mdb)}; DBQ = ' + Server.MapPath('profile.md
ASKER
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)
ASKER
I am still looking forward for the Correct Answer.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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
ASKER
I did not get the Right Answer. I am still unable to connect via jScript.
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
This is a Jscript example
http://www.aspemporium.com/aspEmporium/src/js_srcview.asp?source=database_read.asp
ASKER
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.
Server Side JSCRIPT is available to all Audience same as VBSCRIPTwe use with ASP.
ASKER
Finaly I got the Solution.
Should I accpet an Answer or you guys Would like to Close it?
Should I accpet an Answer or you guys Would like to Close it?
JScript/Javascript cannot connection to database.
Intead you may create different connectionstring for each data connection, if the result didn't works.
regards