BOF or EOF is true?

C

Christo

ADODB.Recordset error '800a0bcd'

Either BOF or EOF is True, or the current record has been deleted.
Requested operation requires a current record.

/update.asp, line 21

thats the error i am getting, my asp code is below....

<%
Dim dbCon
Dim rsUpdate
Dim strSQL
Dim RecordNo

RecordNo = CLng(Request.QueryString("id"))

Set dbCon = Server.CreateObject("ADODB.Connection")
dbCon.Open "DSN=cb2cwh"

Set rsUpdate = Server.CreateObject("ADODB.Recordset")

strSQL = "SELECT tNews.* FROM tNews WHERE id=" & RecordNo

rsUpdate.CursorType = 2
rsUpdate.LockType = 3

rsUpdate.Open strSQL, dbCon
rsUpdate.Fields("title") = Request.Form("title") '<<<<<<<<< LINE 21
rsUpdate.Fields("news") = Request.Form("news")
rsUpdate.fields("date") = Now()
rsUpdate.Update
rsUpdate.Close
Set rsUpdate = Nothing
Set dboCon = Nothing
Response.Redirect "deled_select.asp"
%>

can anyone help me find out what the problem is here I am copying this
script from a website its purely part of learning and i really want to
know why it wont work on my IIS machine. the link to the website is
below.

http://www.webwizguide.info/asp/tutorials/updating_data_from_database.asp

I have had it working previously but it wont work now and there hasnt
been much change.
 
B

Bob Barrows [MVP]

Christo said:
ADODB.Recordset error '800a0bcd'

Either BOF or EOF is True, or the current record has been deleted.
Requested operation requires a current record.

/update.asp, line 21

thats the error i am getting, my asp code is below....

<%
Dim dbCon
Dim rsUpdate
Dim strSQL
Dim RecordNo

RecordNo = CLng(Request.QueryString("id"))

Set dbCon = Server.CreateObject("ADODB.Connection")
dbCon.Open "DSN=cb2cwh"
http://www.aspfaq.com/show.asp?id=2126


Set rsUpdate = Server.CreateObject("ADODB.Recordset")

strSQL = "SELECT tNews.* FROM tNews WHERE id=" & RecordNo

response.write this strSQL variable so you can verify that it contains
the sql statement you expect it to contain. It probably does not contain
what you expect because it is not retrieving any records. Double-check
it by running the sql statement in the query execution tool provided by
whatever database you are using (it is always a good idea to provide the
database type and version when asking database-related questions).

can anyone help me find out what the problem is here I am copying this
script from a website its purely part of learning

Well, you picked a bad one to copy. It's got several issues, the first
of which I pointed out above. Other issues include:

1. using selstar: http://www.aspfaq.com/show.asp?id=2096
2. using a recordset to update data - in asp, recordsets should be used
solely to retrieve readonly data for display purposes. SQL DML (Data
Modification Language - UPDATE, INSERT and DELETE) statements should be
used for data modification. In asp, it is critical to get in and out of
the database as quickly as possible. Cursors (recordsets) are just too
slow when it comes to data modification.
3. Further points to consider:
Your use of dynamic sql is leaving you vulnerable to hackers using sql
injection:
http://mvp.unixwiz.net/techtips/sql-injection.html
http://www.sqlsecurity.com/DesktopDefault.aspx?tabid=23

See here for a better, more secure way to execute your queries by using
parameter markers:
http://groups-beta.google.com/group/microsoft.public.inetserver.asp.db/msg/72e36562fee7804e

Personally, I prefer using stored procedures, or saved parameter queries
as
they are known in Access:

Access:
http://www.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&[email protected]

http://groups.google.com/groups?hl=...=1&[email protected]

SQL Server:
http://tinyurl.com/jyy0

..
 
M

Mike Brind

Christo said:
ADODB.Recordset error '800a0bcd'

Either BOF or EOF is True, or the current record has been deleted.
Requested operation requires a current record.

/update.asp, line 21

thats the error i am getting, my asp code is below....

<%
Dim dbCon
Dim rsUpdate
Dim strSQL
Dim RecordNo

RecordNo = CLng(Request.QueryString("id"))

Set dbCon = Server.CreateObject("ADODB.Connection")
dbCon.Open "DSN=cb2cwh"

Set rsUpdate = Server.CreateObject("ADODB.Recordset")

strSQL = "SELECT tNews.* FROM tNews WHERE id=" & RecordNo

rsUpdate.CursorType = 2
rsUpdate.LockType = 3

rsUpdate.Open strSQL, dbCon
rsUpdate.Fields("title") = Request.Form("title") '<<<<<<<<< LINE 21
rsUpdate.Fields("news") = Request.Form("news")
rsUpdate.fields("date") = Now()
rsUpdate.Update
rsUpdate.Close
Set rsUpdate = Nothing
Set dboCon = Nothing
Response.Redirect "deled_select.asp"
%>

can anyone help me find out what the problem is here I am copying this
script from a website its purely part of learning and i really want to
know why it wont work on my IIS machine. the link to the website is
below.

http://www.webwizguide.info/asp/tutorials/updating_data_from_database.asp

I have had it working previously but it wont work now and there hasnt
been much change.

BOF (beginning of file) is the region before any records. EOF (end of file)
is the region after any records.
________
BOF --> |_______|
| |
Records --> | |
|_______|
EOF --> |_______|


The error message is saying that there are no records that belong to your
select statement, in other words, that middle part is empty. After defining
strSQL in your code, add this in:

Response.Write strSQL
Response.End

This will write the value of strSQL to the browser. You may see that
RecordNo now refers to a record that no longer exists, or it's blank.

Stop using that tutorial. It's horrible. You should not be using a DSN to
connect to a database these days (use the oledb driver instead), and
creating a recordset to update records is awful too. This one is slightly
better: http://w3schools.com/ado/ado_update.asp, although really for this
type of operation, it's easier and safer to create a saved query in Access
and use parameters to update or write records. (I'm assuming you are using
Access, but if not, use stored procedures).

For Access, the simplest way to do this is to open up Access, go the Query
tab and create a new query in Design View. Close the Show Tables dialogue
box and switch to SQL View. Using the example above, type in the SQL clause:

UPDATE tblNews SET title = [p1], news = [p2], [date] = Date() WHERE id=[p3]

[p1] and [p2] are parameter place holders. These are always in square
brackets ( [ ] ), which tells Access to expect a value as a parameter.
[date] is in square brackets because it is a reserved name in Access, and
should never be used for column names. Call the column PostDate or
something else. Then you an remove the square brackets from the field name.
If you Run the query, Access will prompt you for input for each field. Enter
data against each field to test that the query is working. As for debugging,
you've just done it. Save the query as something meaningful - qryUpdateNews
for example.

In your ASP code, you will still need to validate the inputs, such as email
addresses for structure, end dates are after start dates, values are
actually being passed etc, but you do not need to check for quote marks or
delimit the inputs in any way. Since the query was created within Access,
the database already knows what data types to expect.

p1 = Request.Form("title") 'no need to check for apostophes in e.g. King's
Ransom Paid
p2 = Request.Form("news")
p3 = Request.Form("id")


Then, assuming conn is an opened and valid connection object, use the query
name as a method against conn, with a comma-separated list of parameters:

conn.qryUpdatenews p1,p2, p3
conn.close : set conn = nothing
 
F

Firas S Assaad

If that didnt help
send me your database, and i will check it for you. Then i will fully
explain the problem for you

Btw, excuse me guys, i had posted this reply, not based on anybody'd
post, so if it was duplicated please excuse, cause im in a hurry right
now.



Best Regards
Firas S Assaad


Mike said:
Christo said:
ADODB.Recordset error '800a0bcd'

Either BOF or EOF is True, or the current record has been deleted.
Requested operation requires a current record.

/update.asp, line 21

thats the error i am getting, my asp code is below....

<%
Dim dbCon
Dim rsUpdate
Dim strSQL
Dim RecordNo

RecordNo = CLng(Request.QueryString("id"))

Set dbCon = Server.CreateObject("ADODB.Connection")
dbCon.Open "DSN=cb2cwh"

Set rsUpdate = Server.CreateObject("ADODB.Recordset")

strSQL = "SELECT tNews.* FROM tNews WHERE id=" & RecordNo

rsUpdate.CursorType = 2
rsUpdate.LockType = 3

rsUpdate.Open strSQL, dbCon
rsUpdate.Fields("title") = Request.Form("title") '<<<<<<<<< LINE 21
rsUpdate.Fields("news") = Request.Form("news")
rsUpdate.fields("date") = Now()
rsUpdate.Update
rsUpdate.Close
Set rsUpdate = Nothing
Set dboCon = Nothing
Response.Redirect "deled_select.asp"
%>

can anyone help me find out what the problem is here I am copying this
script from a website its purely part of learning and i really want to
know why it wont work on my IIS machine. the link to the website is
below.

http://www.webwizguide.info/asp/tutorials/updating_data_from_database.asp

I have had it working previously but it wont work now and there hasnt
been much change.

BOF (beginning of file) is the region before any records. EOF (end of file)
is the region after any records.
________
BOF --> |_______|
| |
Records --> | |
|_______|
EOF --> |_______|


The error message is saying that there are no records that belong to your
select statement, in other words, that middle part is empty. After defining
strSQL in your code, add this in:

Response.Write strSQL
Response.End

This will write the value of strSQL to the browser. You may see that
RecordNo now refers to a record that no longer exists, or it's blank.

Stop using that tutorial. It's horrible. You should not be using a DSN to
connect to a database these days (use the oledb driver instead), and
creating a recordset to update records is awful too. This one is slightly
better: http://w3schools.com/ado/ado_update.asp, although really for this
type of operation, it's easier and safer to create a saved query in Access
and use parameters to update or write records. (I'm assuming you are using
Access, but if not, use stored procedures).

For Access, the simplest way to do this is to open up Access, go the Query
tab and create a new query in Design View. Close the Show Tables dialogue
box and switch to SQL View. Using the example above, type in the SQL clause:

UPDATE tblNews SET title = [p1], news = [p2], [date] = Date() WHERE id=[p3]

[p1] and [p2] are parameter place holders. These are always in square
brackets ( [ ] ), which tells Access to expect a value as a parameter.
[date] is in square brackets because it is a reserved name in Access, and
should never be used for column names. Call the column PostDate or
something else. Then you an remove the square brackets from the field name.
If you Run the query, Access will prompt you for input for each field. Enter
data against each field to test that the query is working. As for debugging,
you've just done it. Save the query as something meaningful - qryUpdateNews
for example.

In your ASP code, you will still need to validate the inputs, such as email
addresses for structure, end dates are after start dates, values are
actually being passed etc, but you do not need to check for quote marks or
delimit the inputs in any way. Since the query was created within Access,
the database already knows what data types to expect.

p1 = Request.Form("title") 'no need to check for apostophes in e.g. King's
Ransom Paid
p2 = Request.Form("news")
p3 = Request.Form("id")


Then, assuming conn is an opened and valid connection object, use the query
name as a method against conn, with a comma-separated list of parameters:

conn.qryUpdatenews p1,p2, p3
conn.close : set conn = nothing
 
M

Mike Brind

You'll be able to explain it just by looking at the database? Wow!

--
Mike Brind


Firas S Assaad said:
If that didnt help
send me your database, and i will check it for you. Then i will fully
explain the problem for you

Btw, excuse me guys, i had posted this reply, not based on anybody'd
post, so if it was duplicated please excuse, cause im in a hurry right
now.



Best Regards
Firas S Assaad


Mike said:
Christo said:
ADODB.Recordset error '800a0bcd'

Either BOF or EOF is True, or the current record has been deleted.
Requested operation requires a current record.

/update.asp, line 21

thats the error i am getting, my asp code is below....

<%
Dim dbCon
Dim rsUpdate
Dim strSQL
Dim RecordNo

RecordNo = CLng(Request.QueryString("id"))

Set dbCon = Server.CreateObject("ADODB.Connection")
dbCon.Open "DSN=cb2cwh"

Set rsUpdate = Server.CreateObject("ADODB.Recordset")

strSQL = "SELECT tNews.* FROM tNews WHERE id=" & RecordNo

rsUpdate.CursorType = 2
rsUpdate.LockType = 3

rsUpdate.Open strSQL, dbCon
rsUpdate.Fields("title") = Request.Form("title") '<<<<<<<<< LINE 21
rsUpdate.Fields("news") = Request.Form("news")
rsUpdate.fields("date") = Now()
rsUpdate.Update
rsUpdate.Close
Set rsUpdate = Nothing
Set dboCon = Nothing
Response.Redirect "deled_select.asp"
%>

can anyone help me find out what the problem is here I am copying this
script from a website its purely part of learning and i really want to
know why it wont work on my IIS machine. the link to the website is
below.

http://www.webwizguide.info/asp/tutorials/updating_data_from_database.asp

I have had it working previously but it wont work now and there hasnt
been much change.

BOF (beginning of file) is the region before any records. EOF (end of
file)
is the region after any records.
________
BOF --> |_______|
| |
Records --> | |
|_______|
EOF --> |_______|


The error message is saying that there are no records that belong to your
select statement, in other words, that middle part is empty. After
defining
strSQL in your code, add this in:

Response.Write strSQL
Response.End

This will write the value of strSQL to the browser. You may see that
RecordNo now refers to a record that no longer exists, or it's blank.

Stop using that tutorial. It's horrible. You should not be using a DSN
to
connect to a database these days (use the oledb driver instead), and
creating a recordset to update records is awful too. This one is
slightly
better: http://w3schools.com/ado/ado_update.asp, although really for this
type of operation, it's easier and safer to create a saved query in
Access
and use parameters to update or write records. (I'm assuming you are
using
Access, but if not, use stored procedures).

For Access, the simplest way to do this is to open up Access, go the
Query
tab and create a new query in Design View. Close the Show Tables dialogue
box and switch to SQL View. Using the example above, type in the SQL
clause:

UPDATE tblNews SET title = [p1], news = [p2], [date] = Date() WHERE
id=[p3]

[p1] and [p2] are parameter place holders. These are always in square
brackets ( [ ] ), which tells Access to expect a value as a parameter.
[date] is in square brackets because it is a reserved name in Access, and
should never be used for column names. Call the column PostDate or
something else. Then you an remove the square brackets from the field
name.
If you Run the query, Access will prompt you for input for each field.
Enter
data against each field to test that the query is working. As for
debugging,
you've just done it. Save the query as something meaningful -
qryUpdateNews
for example.

In your ASP code, you will still need to validate the inputs, such as
email
addresses for structure, end dates are after start dates, values are
actually being passed etc, but you do not need to check for quote marks
or
delimit the inputs in any way. Since the query was created within Access,
the database already knows what data types to expect.

p1 = Request.Form("title") 'no need to check for apostophes in e.g.
King's
Ransom Paid
p2 = Request.Form("news")
p3 = Request.Form("id")


Then, assuming conn is an opened and valid connection object, use the
query
name as a method against conn, with a comma-separated list of parameters:

conn.qryUpdatenews p1,p2, p3
conn.close : set conn = nothing
 
F

Firas S Assaad

I dont think is need a "high" skill just to know that you can run the
SQL statement in the database and figure out the problem.
Take my advice my friend and "Think out of the box" for a second. Dont
be so routine.


Best Regards
Mike said:
You'll be able to explain it just by looking at the database? Wow!

--
Mike Brind


Firas S Assaad said:
If that didnt help
send me your database, and i will check it for you. Then i will fully
explain the problem for you

Btw, excuse me guys, i had posted this reply, not based on anybody'd
post, so if it was duplicated please excuse, cause im in a hurry right
now.



Best Regards
Firas S Assaad


Mike said:
ADODB.Recordset error '800a0bcd'

Either BOF or EOF is True, or the current record has been deleted.
Requested operation requires a current record.

/update.asp, line 21

thats the error i am getting, my asp code is below....

<%
Dim dbCon
Dim rsUpdate
Dim strSQL
Dim RecordNo

RecordNo = CLng(Request.QueryString("id"))

Set dbCon = Server.CreateObject("ADODB.Connection")
dbCon.Open "DSN=cb2cwh"

Set rsUpdate = Server.CreateObject("ADODB.Recordset")

strSQL = "SELECT tNews.* FROM tNews WHERE id=" & RecordNo

rsUpdate.CursorType = 2
rsUpdate.LockType = 3

rsUpdate.Open strSQL, dbCon
rsUpdate.Fields("title") = Request.Form("title") '<<<<<<<<< LINE 21
rsUpdate.Fields("news") = Request.Form("news")
rsUpdate.fields("date") = Now()
rsUpdate.Update
rsUpdate.Close
Set rsUpdate = Nothing
Set dboCon = Nothing
Response.Redirect "deled_select.asp"
%>

can anyone help me find out what the problem is here I am copying this
script from a website its purely part of learning and i really want to
know why it wont work on my IIS machine. the link to the website is
below.

http://www.webwizguide.info/asp/tutorials/updating_data_from_database.asp

I have had it working previously but it wont work now and there hasnt
been much change.


BOF (beginning of file) is the region before any records. EOF (end of
file)
is the region after any records.
________
BOF --> |_______|
| |
Records --> | |
|_______|
EOF --> |_______|


The error message is saying that there are no records that belong to your
select statement, in other words, that middle part is empty. After
defining
strSQL in your code, add this in:

Response.Write strSQL
Response.End

This will write the value of strSQL to the browser. You may see that
RecordNo now refers to a record that no longer exists, or it's blank.

Stop using that tutorial. It's horrible. You should not be using a DSN
to
connect to a database these days (use the oledb driver instead), and
creating a recordset to update records is awful too. This one is
slightly
better: http://w3schools.com/ado/ado_update.asp, although really for this
type of operation, it's easier and safer to create a saved query in
Access
and use parameters to update or write records. (I'm assuming you are
using
Access, but if not, use stored procedures).

For Access, the simplest way to do this is to open up Access, go the
Query
tab and create a new query in Design View. Close the Show Tables dialogue
box and switch to SQL View. Using the example above, type in the SQL
clause:

UPDATE tblNews SET title = [p1], news = [p2], [date] = Date() WHERE
id=[p3]

[p1] and [p2] are parameter place holders. These are always in square
brackets ( [ ] ), which tells Access to expect a value as a parameter.
[date] is in square brackets because it is a reserved name in Access, and
should never be used for column names. Call the column PostDate or
something else. Then you an remove the square brackets from the field
name.
If you Run the query, Access will prompt you for input for each field.
Enter
data against each field to test that the query is working. As for
debugging,
you've just done it. Save the query as something meaningful -
qryUpdateNews
for example.

In your ASP code, you will still need to validate the inputs, such as
email
addresses for structure, end dates are after start dates, values are
actually being passed etc, but you do not need to check for quote marks
or
delimit the inputs in any way. Since the query was created within Access,
the database already knows what data types to expect.

p1 = Request.Form("title") 'no need to check for apostophes in e.g.
King's
Ransom Paid
p2 = Request.Form("news")
p3 = Request.Form("id")


Then, assuming conn is an opened and valid connection object, use the
query
name as a method against conn, with a comma-separated list of parameters:

conn.qryUpdatenews p1,p2, p3
conn.close : set conn = nothing
 
C

Christo

cheers for all your help, after reading your advice and asfter getting
advice from other people around me I have decided to redesign my
database in mysql, and am probably going to go over to php, I know i
shouldn't be mentioning this here in an ASP group but just incase you
guys thought I was being ignorant by not replying, I appreciate your
help, unfortunately Since then i have come accorss some deeper problems
with my IIS setup on my machine, so again moving over to apache.

Thanks for your help all

:)

Chris
I dont think is need a "high" skill just to know that you can run the
SQL statement in the database and figure out the problem.
Take my advice my friend and "Think out of the box" for a second. Dont
be so routine.


Best Regards
Mike said:
You'll be able to explain it just by looking at the database? Wow!

--
Mike Brind


Firas S Assaad said:
If that didnt help
send me your database, and i will check it for you. Then i will fully
explain the problem for you

Btw, excuse me guys, i had posted this reply, not based on anybody'd
post, so if it was duplicated please excuse, cause im in a hurry right
now.



Best Regards
Firas S Assaad


Mike Brind wrote:
ADODB.Recordset error '800a0bcd'

Either BOF or EOF is True, or the current record has been deleted.
Requested operation requires a current record.

/update.asp, line 21

thats the error i am getting, my asp code is below....

<%
Dim dbCon
Dim rsUpdate
Dim strSQL
Dim RecordNo

RecordNo = CLng(Request.QueryString("id"))

Set dbCon = Server.CreateObject("ADODB.Connection")
dbCon.Open "DSN=cb2cwh"

Set rsUpdate = Server.CreateObject("ADODB.Recordset")

strSQL = "SELECT tNews.* FROM tNews WHERE id=" & RecordNo

rsUpdate.CursorType = 2
rsUpdate.LockType = 3

rsUpdate.Open strSQL, dbCon
rsUpdate.Fields("title") = Request.Form("title") '<<<<<<<<< LINE 21
rsUpdate.Fields("news") = Request.Form("news")
rsUpdate.fields("date") = Now()
rsUpdate.Update
rsUpdate.Close
Set rsUpdate = Nothing
Set dboCon = Nothing
Response.Redirect "deled_select.asp"
%>

can anyone help me find out what the problem is here I am copying this
script from a website its purely part of learning and i really want to
know why it wont work on my IIS machine. the link to the website is
below.

http://www.webwizguide.info/asp/tutorials/updating_data_from_database.asp

I have had it working previously but it wont work now and there hasnt
been much change.


BOF (beginning of file) is the region before any records. EOF (end of
file)
is the region after any records.
________
BOF --> |_______|
| |
Records --> | |
|_______|
EOF --> |_______|


The error message is saying that there are no records that belong to your
select statement, in other words, that middle part is empty. After
defining
strSQL in your code, add this in:

Response.Write strSQL
Response.End

This will write the value of strSQL to the browser. You may see that
RecordNo now refers to a record that no longer exists, or it's blank.

Stop using that tutorial. It's horrible. You should not be using a DSN
to
connect to a database these days (use the oledb driver instead), and
creating a recordset to update records is awful too. This one is
slightly
better: http://w3schools.com/ado/ado_update.asp, although really for this
type of operation, it's easier and safer to create a saved query in
Access
and use parameters to update or write records. (I'm assuming you are
using
Access, but if not, use stored procedures).

For Access, the simplest way to do this is to open up Access, go the
Query
tab and create a new query in Design View. Close the Show Tables dialogue
box and switch to SQL View. Using the example above, type in the SQL
clause:

UPDATE tblNews SET title = [p1], news = [p2], [date] = Date() WHERE
id=[p3]

[p1] and [p2] are parameter place holders. These are always in square
brackets ( [ ] ), which tells Access to expect a value as a parameter.
[date] is in square brackets because it is a reserved name in Access, and
should never be used for column names. Call the column PostDate or
something else. Then you an remove the square brackets from the field
name.
If you Run the query, Access will prompt you for input for each field.
Enter
data against each field to test that the query is working. As for
debugging,
you've just done it. Save the query as something meaningful -
qryUpdateNews
for example.

In your ASP code, you will still need to validate the inputs, such as
email
addresses for structure, end dates are after start dates, values are
actually being passed etc, but you do not need to check for quote marks
or
delimit the inputs in any way. Since the query was created within Access,
the database already knows what data types to expect.

p1 = Request.Form("title") 'no need to check for apostophes in e.g.
King's
Ransom Paid
p2 = Request.Form("news")
p3 = Request.Form("id")


Then, assuming conn is an opened and valid connection object, use the
query
name as a method against conn, with a comma-separated list of parameters:

conn.qryUpdatenews p1,p2, p3
conn.close : set conn = nothing
 
M

Mike Brind

Think out of the box? For a BOF or EOF?? Gee - thanks for the advice.
I'll bear it in mind.

Firas S Assaad said:
I dont think is need a "high" skill just to know that you can run the
SQL statement in the database and figure out the problem.
Take my advice my friend and "Think out of the box" for a second. Dont
be so routine.


Best Regards
Mike said:
You'll be able to explain it just by looking at the database? Wow!

--
Mike Brind


Firas S Assaad said:
If that didnt help
send me your database, and i will check it for you. Then i will fully
explain the problem for you

Btw, excuse me guys, i had posted this reply, not based on anybody'd
post, so if it was duplicated please excuse, cause im in a hurry right
now.



Best Regards
Firas S Assaad


Mike Brind wrote:
ADODB.Recordset error '800a0bcd'

Either BOF or EOF is True, or the current record has been deleted.
Requested operation requires a current record.

/update.asp, line 21

thats the error i am getting, my asp code is below....

<%
Dim dbCon
Dim rsUpdate
Dim strSQL
Dim RecordNo

RecordNo = CLng(Request.QueryString("id"))

Set dbCon = Server.CreateObject("ADODB.Connection")
dbCon.Open "DSN=cb2cwh"

Set rsUpdate = Server.CreateObject("ADODB.Recordset")

strSQL = "SELECT tNews.* FROM tNews WHERE id=" & RecordNo

rsUpdate.CursorType = 2
rsUpdate.LockType = 3

rsUpdate.Open strSQL, dbCon
rsUpdate.Fields("title") = Request.Form("title") '<<<<<<<<< LINE 21
rsUpdate.Fields("news") = Request.Form("news")
rsUpdate.fields("date") = Now()
rsUpdate.Update
rsUpdate.Close
Set rsUpdate = Nothing
Set dboCon = Nothing
Response.Redirect "deled_select.asp"
%>

can anyone help me find out what the problem is here I am copying
this
script from a website its purely part of learning and i really want
to
know why it wont work on my IIS machine. the link to the website is
below.

http://www.webwizguide.info/asp/tutorials/updating_data_from_database.asp

I have had it working previously but it wont work now and there
hasnt
been much change.


BOF (beginning of file) is the region before any records. EOF (end of
file)
is the region after any records.
________
BOF --> |_______|
| |
Records --> | |
|_______|
EOF --> |_______|


The error message is saying that there are no records that belong to
your
select statement, in other words, that middle part is empty. After
defining
strSQL in your code, add this in:

Response.Write strSQL
Response.End

This will write the value of strSQL to the browser. You may see that
RecordNo now refers to a record that no longer exists, or it's blank.

Stop using that tutorial. It's horrible. You should not be using a
DSN
to
connect to a database these days (use the oledb driver instead), and
creating a recordset to update records is awful too. This one is
slightly
better: http://w3schools.com/ado/ado_update.asp, although really for
this
type of operation, it's easier and safer to create a saved query in
Access
and use parameters to update or write records. (I'm assuming you are
using
Access, but if not, use stored procedures).

For Access, the simplest way to do this is to open up Access, go the
Query
tab and create a new query in Design View. Close the Show Tables
dialogue
box and switch to SQL View. Using the example above, type in the SQL
clause:

UPDATE tblNews SET title = [p1], news = [p2], [date] = Date() WHERE
id=[p3]

[p1] and [p2] are parameter place holders. These are always in square
brackets ( [ ] ), which tells Access to expect a value as a parameter.
[date] is in square brackets because it is a reserved name in Access,
and
should never be used for column names. Call the column PostDate or
something else. Then you an remove the square brackets from the field
name.
If you Run the query, Access will prompt you for input for each field.
Enter
data against each field to test that the query is working. As for
debugging,
you've just done it. Save the query as something meaningful -
qryUpdateNews
for example.

In your ASP code, you will still need to validate the inputs, such as
email
addresses for structure, end dates are after start dates, values are
actually being passed etc, but you do not need to check for quote
marks
or
delimit the inputs in any way. Since the query was created within
Access,
the database already knows what data types to expect.

p1 = Request.Form("title") 'no need to check for apostophes in e.g.
King's
Ransom Paid
p2 = Request.Form("news")
p3 = Request.Form("id")


Then, assuming conn is an opened and valid connection object, use the
query
name as a method against conn, with a comma-separated list of
parameters:

conn.qryUpdatenews p1,p2, p3
conn.close : set conn = nothing
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top