View Full Version : How to connect database using Javascript in ASP page ?

09-03-2011, 06:29 AM
Hello Everyone,

I am using Javascript in ASP page to connect to the database. I am not able to figure out where is the problem.
Gettting this error->

Error Type:
Microsoft OLE DB Provider for SQL Server (0x80004005)
[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied.
/MyWeb/test.asp, line 9

My code is->

<%@ Language = JavaScript %>
var myconnection
var myrecordset
var connectionString

myconnection = Server.CreateObject("adodb.connection")
connectionString = "Provider=SQLOLEDB.1;Password=myPwd;Persist Security Info=True;User ID=myId;Initial Catalog=MyTable;Data Source=MyCompName\MyDBINSTANCE"
myconnection.Open(connectionString, myconnection);


If someone could please guide me in the right direction I would greatly apprieciate it.

Thanking You.