Log in

View Full Version : ASP Form for update database in Sqlserver2000


mohammad
Mar 3, 2003, 05:12 AM
Hello
About how can I make update in database that was based in SQL server2000

Details:
I made web pages in ASP, and I want to make update in database from the ASP Page
I made the code but it gave me a message that "operation is not allowed when the object is closed"

Bellow you can see the codes that I made them...


[[[[[
---------------------------------------------------------------------------------------------------
Update.asp:


<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<%
Frm=Request.Form
Strname=Request.Form ("name")
Strlname=Request.Form ("lname")
Strphone=Request.Form ("phone")
Strid=Request.Form ("id")
A=Request.QueryString ("name")
B=Request.QueryString ("lname")
C=Request.QueryString ("phone")
Set cn =server.CreateObject ("adodb.connection")
Cn.Open "library"
Sql="update test set name = & strname & , lname = & strlname & , phone = & strphone & where id = & strid & "
Set rs = server.CreateObject ("Adodb.recordset")
Rs.Open sql,cn,1,2
Do while not rs.EOF

hswes
Apr 4, 2003, 05:50 PM
It looks fine, but you forget to tell in your asp script what database server he should connect to. Just visit the Microsoft website and ask for asp and you find hundreds of samples how to connect to a sql server database, or if you like to have it simpler use sql server web publishing wizard and you see in the asp page how he connects.
Good luck

Hswes