Groups | Blog | Home
all groups > dotnet jscript > may 2004 >

dotnet jscript : Connection string in javascript



B0nj
5/5/2004 5:31:02 AM
I'm trying to create some client side code to connect to a SQL server database from javascript but it just will not play. There must be something missing that I've not had to do before, because connection strings work from every other language - C#, C++, VB6, VBScript... you name it. Javascript just won't have it. i'm using the form

var cndb = new ActiveXObject("adodb.connection")
cndb.Open("Provider=SQLOLEDB;Data Source=myserversip\myserversinstance;User ID=myusername;Password=mypass")

and expecting it to work, but it's not. I'm using it in a html page. It works fine to connect to Access, although I have to reverse the \ to unix-style ones, such as / in the file name of the database
Please help

Viatcheslav V. Vassiliev
5/5/2004 4:41:27 PM
You should escape '\' characters, not reverse them:

cndb.Open("Provider=SQLOLEDB;Data Source=myserversip\\myserversinstance;User
ID=myusername;Password=mypass");

may be add "Initial catalog=XXX" to specify database to which you are
connecting.

If this does not help, what is error message?

//------------------------------------
Regards,
Vassiliev V. V.
http://www-sharp.com -
Scripting/HTA/.Net Framework IDE

"B0nj" <anonymous@discussions.microsoft.com> ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × ÎÏ×ÏÓÔÑÈ
ÓÌÅÄÕÀÝÅÅ: news:CAFE8431-34D0-4052-A5DE-8BDCF910E906@microsoft.com...
[quoted text, click to view]
database from javascript but it just will not play. There must be something
missing that I've not had to do before, because connection strings work from
every other language - C#, C++, VB6, VBScript... you name it. Javascript
just won't have it. i'm using the form:
[quoted text, click to view]
works fine to connect to Access, although I have to reverse the \ to
unix-style ones, such as / in the file name of the database.
[quoted text, click to view]

AddThis Social Bookmark Button