Wrox Programmer Forums
|
Classic ASP Components Discussions specific to components in ASP 3.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Components section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 10th, 2003, 05:57 PM
Registered User
 
Join Date: Sep 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Add new record in SQL Server database

Hi,

I am getting an error:

Error Type:
Active Server Pages, ASP 0113 (0x80004005)
The maximum amount of time for a script to execute was exceeded. You can change this limit by specifying a new value for the property Server.ScriptTimeout or by changing the value in the IIS administration tools.

At the same time whenever I try to open SQL SERVER I am getting the message: SQL SERVER IS NOT RUNNING. ARE YOU SURE YOU WANT TO CONNECT

I wrote this script in ASP to ADD new record in SQL SERVER DATABASE

FileName: sha_BankConnection.asp

<html>
<body>
<%
dim str
str = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=Bank;Data Source=SHAILY"
%>
</body>
</html>

FileName: AddnewRecord.asp


<html>
<body>
<%
dim conn,rec, ID

set rec = server.createobject("ADODB.Recordset")
rec.open "select * from Account", str

do while not rec.EOF
  response.write rec("AccountID")
  response.write "<br>"
loop

ID = 1234-5678
rec.MoveLast
rec.addnew

rec("AccountID") = ID
rec("HolderName") = "Sally S. Bhat"
rec.update
rec.close

rec.open "select * from Account where AccountID = " & ID ,str

if rec.EOF then
 response.write "New record not found"
else
 response.write "New record is added"
end if

rec.close
set rec = nothing
%>
</body>
</html>



 
Old September 17th, 2003, 10:48 AM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 205
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The first error reflects that the script is taking a long time to process. IIS has a script time out processing that cuts off ASPs if they are taking to long. This can be expanded either programatically from the response object or as a whole in IIS (the default I think is 90 seconds).

The secod error appears to be the main cause. You appear to have a connection issue. Here are some things to check:
1. user name and password (are they correct. Try to log in manually through Enterprise mnager or query analyzer).
2. Is the database running and online.
3. Is ado 2.6 (I think this installs the sqloleddb.1 drivers) or higher installed on the server processing the request.
4. Is it taking a long time to connect and the script limit is cutting you off.

Yehuda
 
Old September 24th, 2003, 01:15 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 171
Thanks: 0
Thanked 1 Time in 1 Post
Default

First of all the "SQL SERVER IS NOT RUNNING. ARE YOU SURE YOU WANT TO CONNECT" message is normal. It happens when you try to open the MMC doesn't it? Happens to me all the time on versions of SQL 7.0.

Try this...

FileName: sha_BankConnection.inc
<%
set db = server.createobject("adodb.connection")
db.connectionString = "provider=sqloledb.1; user id=MyUserId; password=MyPassword; data source=MyServer; initial catalog=MyDatabase"
db.mode=3
db.cursorlocation=3
db.open
%>


FileName: AddNewRecord.asp

<%
    Value1 = "1234-5678"
    Value2 = "Sally S. Bhat"
' (Remember the quotes for the string values.)

    set rs = server.createobject("adodb.recordset")
    sql = "select * from account"
    rs.open sql, db, 3, 3
    rs.addnew
    rs("AccountId") = Value1
    rs("HolderName") = Value2
    rs.update
%>

You don't even need the HTML unless you plan on displaying something as the record is being processed.

 
Old September 24th, 2003, 01:16 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 171
Thanks: 0
Thanked 1 Time in 1 Post
Default

By the way. Let me know how that works for you. I'm curious.






Similar Threads
Thread Thread Starter Forum Replies Last Post
HELP ME to add a record to a database using ASP kumail Classic ASP Databases 3 August 18th, 2005 05:33 AM
errro trying to insert record to sql server method ASP.NET 1.0 and 1.1 Basics 1 May 20th, 2005 08:24 PM
How to unlock record in SQL Server database DDB001 SQL Server 2000 2 August 2nd, 2004 09:46 AM
Cannot add database connection in server explorer bbhill VS.NET 2002/2003 1 June 30th, 2003 09:14 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.