Hi, i am having a problem with connecting ASP with MSSQL SEVER 2005 EXPRESS EDITION, i am writing ASP code using javascript.
look at this peace of code:
var myConnect = "Provider=SQLNCLI;Data Source=.\SQLEXPRESS;Initial Catalog=quiz;User ID=factory1;Password = 123;";
var ConnectObj = Server.CreateObject("ADODB.Connection");
var RS = Server.CreateObject("ADODB.Recordset");
var sql="select * from [Quiz.mdf].dbo.Question";
ConnectObj.Open(myConnect);
RS.Open(sql,ConnectObj,adOpenForwardOnly,adLockRea dOnly,adCmdText);
The IIS throws an error says:
"Microsoft SQL Native Client (0x80004005)
Named Pipes Provider: Could not open a connection to SQL Server [53]. "
at "ConnectObj.Open(myConnect);"
Any body can give me a help?
10 4061
Javascript is not built to connect to databases.
Javascript runs locally on the users machine. So your not going to be able to connect to a server side database.
If you want to write ASP pages that connect to a SQL database you need to write server side ASP\vbscript, or use coldfusion or some other server side scripting.
You can use JAVA to connect to databases but these would be .jsp server side files as well. Also thats totally different from javascript which is usually strictly used for event handling on the client side.
Technically actually there are "tricks" you can do to use javascript to CALL server side scripts to execute database connections.
But the way you are trying to implement the code aboave is not correct. The code you have above is closer to vbscript then javascript.
Anyway here is an interesting trick in using JDBC trick to use javascript for database connectivity locally. I would probably NOT recommend trying this though if you are unfamiliar with web programming methods Javascript servlet trick
actually looks like he's writing in JSP which is the same as ASP, but with jscript as the language rather than vbscript. If that's the case, then yes you can connect with javascript.
That aside, I don't see what's wrong. I'm not a jscript guru (I don't think many people are) but I think your db connection is the problem, regardless. db connections can be a real headache. I always use a dsn to connect, it takes more work to set up, but then it goes smoother. If you have any questions about setting up a DSN or connecting to it, I would be happy to help you out.
Jared
Thanks jeffstl and jhardman i want to give this reply to jeffstl.
I made as suggestion and i tried it the same code with vbscript, the code is:
<%
set conn=Server.CreateObject("ADODB.Connection")
Dim myVBconnect = "Provider=SQLNCLI;Data Source=.\SQLEXPRESS;Initial Catalog=quiz;User ID=factory1;Password = 123;";
conn.Open myVBconnect
%>
And i get this error message Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/MyWeb/yaRab2.asp, line 3, column 16
Dim myVBconnect = "Provider=SQLNCLI;Data Source=.\SQLEXPRESS;Initial Catalog=quiz.mdf;User ID=factory1;Password = 123;"
Thanks jeffstl and jhardman, i want to give this reply to jeffstl.
I made as your suggestion and i tried the same code with vbscript, the code is:
<%
set conn=Server.CreateObject("ADODB.Connection")
Dim myVBconnect = "Provider=SQLNCLI;Data Source=.\SQLEXPRESS;Initial Catalog=quiz;User ID=factory1;Password = 123;"
conn.Open myVBconnect
%>
And i get this error message Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/MyWeb/yaRab2.asp, line 3, column 16
Dim myVBconnect = "Provider=SQLNCLI;Data Source=.\SQLEXPRESS;Initial Catalog=quiz.mdf;User ID=factory1;Password = 123;"
Sorry I did not explain what I meant fully. IIS alone cannot run JSP. You need a java server to do that. Like Apache or Tomcat.
Another note, things like ADODB, and RS.Open are strictly Microsoft controls that compile and run on IIS. (vbscript controls, javascript will have no idea what they are).
Java and javascript are two completely different things and to my knowledge you cannot use javascript to connect to a database.
You can use Java (Java Server Pages, Java Beans, etc) which are .jsp's which again by default can only deploy on a Apache or Tomcat server.
All that being said, your code all looks to me like vbscript, ASP code. And the errors are IIS errors. So the bottom line is you are not coding in javascript here, you are using vbscript. At first glance all I can suggest is to modify your connection string. It seems to me a path or provider problem.
As Jhardman said....connection strings are rough sometimes because they are very dependant on local settings, paths, types of databases, etc. I suggest either trying a connection string you know for certain will work first, and see if you are missing a provider reference, or a different version of a provider or if the path needs to be modified.
Java and javascript are two completely different things and to my knowledge you cannot use javascript to connect to a database.
You can use Java (Java Server Pages, Java Beans, etc) which are .jsp's which again by default can only deploy on a Apache or Tomcat server.
Sorry, Jeff. jsp's can run on IIS alone, but they need to be written in microsoft's implementation of javascript, which is actually called "jscript". This does work on IIS exactly like vbscript. This is why some coders specify which language they use in their asp pages.
that said, khalid, your vbscript syntax is incorrect. try this: - <%
-
set conn=Server.CreateObject("ADODB.Connection")
-
Dim myVBconnect
-
myVBconnect = "Provider=SQLNCLI;Data Source=.\SQLEXPRESS;Initial Catalog=quiz;User ID=factory1;Password = 123;"
-
conn.Open myVBconnect
-
%>
Jared
Thanks jeffstl and jhardman, i want to give this reply to jeffstl.
I made as your suggestion and i got this error message from the IIS:
Error Type:
Microsoft SQL Native Client (0x80004005)
Cannot open database "quiz" requested by the login. The login failed.
I think its a permission problem, by the way i changed my server authentication mode to SQL Server and Windows authntication mode in MS SQL SERVER MANAGEMENT STUDIO EXPRESS 2005 and i made my user id "factory1" and my password "123" and i allowed remote connections from the SQL SERVER SURFACE AREA CONFIGURATION.
I also made a remote connection from NetBeans (Java programming language) to the same database, user id, and password, and it worked perfectly.
Thanks.
Thanks jhardman, i found where was he problem in my code
<%
set conn=Server.CreateObject("ADODB.Connection")
Dim myVBconnect
myVBconnect = "Provider=SQLNCLI;Data Source=.\SQLEXPRESS;Initial Catalog=quiz;User ID=factory1;Password = 123;"
conn.Open myVBconnect
%>
when i changed the Initial Catalog from "quiz" to "quiz.mdf" it worked, so this is the code:
<%
set conn=Server.CreateObject("ADODB.Connection")
Dim myVBconnect
myVBconnect = "Provider=SQLNCLI;Data Source=.\SQLEXPRESS;Initial Catalog=quiz.mdf;User ID=factory1;Password = 123;"
conn.Open myVBconnect
%>
Another thing i'd like to thank jeffstl and i'd like to tell him that his suggestion is right so when i try the same code above which is the one who worked in javascript an error message is thrown from the IIS and says:
Microsoft SQL Native Client (0x80004005)
Named Pipes Provider: Could not open a connection to SQL Server [53].
That's probably because i am using ASP/javascript because the same code in vbscript works.
Thanks to ALLAH first then to jeffstl and jhardman for their help.
Sorry, Jeff. jsp's can run on IIS alone, but they need to be written in microsoft's implementation of javascript, which is actually called "jscript". This does work on IIS exactly like vbscript. This is why some coders specify which language they use in their asp pages.
OK. Hm
I don't doubt you. That is interesting. I just always thought that javascript was strictly for event handling and local execution and some very primitive DHTML type of uses.
I never knew it could be used for a full fledged application like that with database connectivity, etc unless you were actually using JAVA.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: mj |
last post by:
Hello, thanks for the help.
I am running a WinXP Pro w/ SP2 (my home computer, with ZoneAlarm
firewall)
Apache 2.0.52
MySQL 4.1.7
PHP 5.1.0-dev
I have developed a PHP/MySQL web app that...
|
by: QLD_AU |
last post by:
Has anyone see the following error ?
VS 2005 Installs ok, however the SQL Mobile Edition (part of a full install)
fails with the following error ?
With Thanks
Jason
|
by: Peter |
last post by:
I've purchased VS.NET 2005 Standard and have tried to install SQL Server
2005 Express, but get the following error in the error log.
Please could someone help me....
Microsoft SQL Server 2005...
|
by: Chris |
last post by:
Don't know if there is a simple solution for this one or not. When
running SQL server on a machine with 2000 loaded and the complete SQL
package I don't have any issues. Now I'm trying to login...
|
by: bg_ie |
last post by:
Hi,
I like to develope an application which uses a MsSQL database. I
believe that C# works really well with MsSQL. To start with, I'd like
to host the sql server locally on my machine as I...
|
by: Light |
last post by:
Hi all,
I posted this question in the sqlserver.newusers group but I am not getting
any response there so I am going to try it on the fine folks here:).
I inherited some legacy ASP codes in my...
|
by: raylopez99 |
last post by:
I am trying to program a database from inside C++.NET via Visual
Studio 2005 using the ADO.NET set of classes, but this I believe is a
SQL Server 2005 Express permissions question under Windows XP...
|
by: Olegus |
last post by:
Hello,
in order to perform backup/restore MSSQL database using SMO, one needs
to reference several namespaces in a backup class :
using Microsoft.SqlServer.Management.Common;
using...
|
by: =?Utf-8?B?QWlya29u?= |
last post by:
I am currently using SQLEXPRESS as a local db file and it works fine when I
access it with C#. However, when I try move the whole application and the db
to another computer running the SQL standard...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |