Skip to main content
Participating Frequently
Oct 27, 2009 5:35 PM UTC
Question

Pull information from database and update

Hello all,

First off, how do you read these forums with a newsreader? I can't seem to find the server address.  I haven't been here for a long time. Thanks for the information.

Second.

I have a web page that is linked to a SQL server database.

I created a recordset to pull the number out of a field in a table in that database.  I now want to create some coding that says look at this field, display it and then add a number to it.  The field is always a number.

I have as follows (only in part):

set rsCasenumber = Server.CreateObject("ADODB.Recordset")
rsCasenumber.ActiveConnection = MM_ClientsWPrime_STRING
rsCasenumber.Source = "SELECT *  FROM subcounters"
rsCasenumber.CursorType = 0
rsCasenumber.CursorLocation = 2
rsCasenumber.LockType = 3
rsCasenumber.Open()
rsCasenumber_numRows = 0

If Request("MM_insert")<> "" Then
rsClients.AddNew
rsClients("Casenum")=rsCasenumber("countervalue")

rsClients.Update
rsClients.Requery

now how do I say update rsCasenumber("countervalue") = the number plus one?

Thanks.

This topic is closed to new replies. Start a new post to keep the conversation going.

7 replies

Participating Frequently
Oct 27, 2009 6:03 PM UTC

>First off, how do you read these forums with a newsreader?

You can't. These forums are no longer propogated to nntp.

>now how do I say update rsCasenumber("countervalue") = the number plus one?

I'm not sure which number you mean, but assuming itself

rsCasenumber("countervalue") = rsCasenumber("countervalue") + 1

rsCasenumber.Update

Translate
poohgcAuthor
Participating Frequently
Oct 27, 2009 7:48 PM UTC

GREAT! One more thing.

I have a spot where a session variable is passed to the next page. I changed some code so I believe my variable never turns out to what it is supposed to be, therefore, things fail.

On the first page I create recordsets to enable me to insert stuff.

set rsClients = Server.CreateObject("ADODB.Recordset")
rsClients.ActiveConnection = MM_connNewdatabase_STRING
rsClients.Source = "SELECT *  FROM CLIENTSW  ORDER BY CASENUM DESC"
rsClients.CursorType = 0
rsClients.CursorLocation = 2
rsClients.LockType = 3
rsClients.Open()
rsClients_numRows = 0

set rsCasenumber = Server.CreateObject("ADODB.Recordset")
rsCasenumber.ActiveConnection = MM_connNewdatabase_STRING
rsCasenumber.Source = "SELECT *  FROM subcounters"
rsCasenumber.CursorType = 0
rsCasenumber.CursorLocation = 2
rsCasenumber.LockType = 3
rsCasenumber.Open()
rsCasenumber_numRows = 0

Then I do some stuff and pull off the insert

If Request("MM_insert")<> "" Then
rsClients.AddNew
rsClients("Casenum")=rsCasenumber("countervalue")

rsClients.Update

Then I take the code you gave me and add "1" to the number in countervalue
rsCasenumber("countervalue") = rsCasenumber("countervalue") + 1
rsCasenumber.Update

Then I requery the rsClients recordset (I believe this is where it is failing) When I requery this rsClients("Casenum") would then equal rscasenumber ("countervalue") which is now a different number!
rsClients.Requery

Then I say
Session("UserID")=rsClients("CASENUM")
Session("email")=Request.Form("EMailAddress")
response.redirect "done3.asp"

Once I get to the next page it says:

Dim rsClients__svuserid
rsClients__svuserid = "0"
if (Session("UserID") <> "") then rsClients__svuserid = Session("UserID")
%>

<%
set rsClients = Server.CreateObject("ADODB.Recordset")
rsClients.ActiveConnection = MM_connNewdatabase_STRING
rsClients.Source = "SELECT *  FROM CLIENTSW  WHERE CASENUM=" + Replace(rsClients__svuserid, "'", "''") + "  ORDER BY CASENUM"
rsClients.CursorType = 0
rsClients.CursorLocation = 2
rsClients.LockType = 3
rsClients.Open()
rsClients_numRows = 0
%>

I think the problem is that the new Session("UserID") never equals the casenumber because that rsclients recordset = the countervalue which has now changed.

How do I get around this? At the end of the second page I send an email and cannot get connected to it because I think the Session("UserID") never comes out correct.

Any suggestions on how I can get around this?

Thanks.

Translate
Participating Frequently
Oct 27, 2009 8:40 PM UTC

A little context would be helpful. Please explain a little about what you are trying to achieve; what this application actually is doing, workflow, etc.

Translate