Dear all
I have a javascript function which embeds ASP script for inserting data
into database. After the data is inserted database, I select the
maximum id (the latest inserted record id). But, it always select the
previous id. It seems the database hasn't been refreshed after insert a
new row.
my code is like
set objrs = server.createob ject("ADO.recor dset")
objrs.open "myTableNam e", objDBConnection
objrs.AddNew
objrs.Fields("F oreignID") = Request("foreig nid")
objrs.Fields("F irstName") = Request("firstn ame")
objrs.Fields("L astName") = Request("lastna me")
objrs.Fields("P hone") = Request("phone" )
objrs.update
objrs.close
objrs.open "select max("PrimaryID" ) from tbl_myTable", objDBConnection
No matter I use objrs.refresh or objrs.requery instead of objrs.close.
The database is not refreshed. How can I refresh the database after I
add a new row in it? Please give me some suggestions.
Cheers
Bon 3 6243
Scrap the whole way you're doing this and used a stored procedure that
returns SCOPE_IDENTITY. And have the stored procedure handle the insert
instead of creating a recordset object the way you're doing. http://www.aspfaq.com/show.asp?id=2174
Ray at work
"Bon" <bo***********@ gmail.comwrote in message
news:11******** **************@ h48g2000cwc.goo glegroups.com.. .
Dear all
I have a javascript function which embeds ASP script for inserting data
into database. After the data is inserted database, I select the
maximum id (the latest inserted record id). But, it always select the
previous id. It seems the database hasn't been refreshed after insert a
new row.
my code is like
set objrs = server.createob ject("ADO.recor dset")
objrs.open "myTableNam e", objDBConnection
objrs.AddNew
objrs.Fields("F oreignID") = Request("foreig nid")
objrs.Fields("F irstName") = Request("firstn ame")
objrs.Fields("L astName") = Request("lastna me")
objrs.Fields("P hone") = Request("phone" )
objrs.update
objrs.close
objrs.open "select max("PrimaryID" ) from tbl_myTable", objDBConnection
No matter I use objrs.refresh or objrs.requery instead of objrs.close.
The database is not refreshed. How can I refresh the database after I
add a new row in it? Please give me some suggestions.
Cheers
Bon
I created a stored procedure for inserting new data to database and
then select scope_identity. The returned ID result is correct when i
run the SP. But, ASP recordset return a wrong result. It always return
the previous ID. For example, the current ID is 100. After I call the
SP from ASP page, SP is run and the ID is 101. But, the ASP recordset
would return 100. Any suggestion?
My ASP code is embedded in javascript :
<%
Dim objrs-dr
%>
function AddRow_clk()
{
'use xmlhttp to pass parameters
....
<%
Set objrs_dr = dbconnection.ex ecute("Exec sp_stored_proce dure_name
@param1='" & Request("Name") & "',@param2= '" & Request("Addres s") &
"'")
session("Return edScopeID") = objrs_dr.Fields ("SPReturnedID" )
%>
alert ( <%=session("Ret urnedScopeID")% );
....
}
I use Javascript to test the returned result. It always returns 100
instead of 101. Could you give me some suggestions?
Cheers
Bon
Ray Costanzo [MVP] 寫道:
Scrap the whole way you're doing this and used a stored procedure that
returns SCOPE_IDENTITY. And have the stored procedure handle the insert
instead of creating a recordset object the way you're doing.
http://www.aspfaq.com/show.asp?id=2174
Ray at work
"Bon" <bo***********@ gmail.comwrote in message
news:11******** **************@ h48g2000cwc.goo glegroups.com.. .
Dear all
I have a javascript function which embeds ASP script for inserting data
into database. After the data is inserted database, I select the
maximum id (the latest inserted record id). But, it always select the
previous id. It seems the database hasn't been refreshed after insert a
new row.
my code is like
set objrs = server.createob ject("ADO.recor dset")
objrs.open "myTableNam e", objDBConnection
objrs.AddNew
objrs.Fields("F oreignID") = Request("foreig nid")
objrs.Fields("F irstName") = Request("firstn ame")
objrs.Fields("L astName") = Request("lastna me")
objrs.Fields("P hone") = Request("phone" )
objrs.update
objrs.close
objrs.open "select max("PrimaryID" ) from tbl_myTable", objDBConnection
No matter I use objrs.refresh or objrs.requery instead of objrs.close.
The database is not refreshed. How can I refresh the database after I
add a new row in it? Please give me some suggestions.
Cheers
Bon
Try response.write-ing the new id to the page directly to see its
value. Your asp could be returning the correct value, but the js
function might not be doing what you think it is.
--
Mike Brind
Bon wrote:
I created a stored procedure for inserting new data to database and
then select scope_identity. The returned ID result is correct when i
run the SP. But, ASP recordset return a wrong result. It always return
the previous ID. For example, the current ID is 100. After I call the
SP from ASP page, SP is run and the ID is 101. But, the ASP recordset
would return 100. Any suggestion?
My ASP code is embedded in javascript:
<%
Dim objrs-dr
%>
function AddRow_clk()
{
'use xmlhttp to pass parameters
...
<%
Set objrs_dr = dbconnection.ex ecute("Exec sp_stored_proce dure_name
@param1='" & Request("Name") & "',@param2= '" & Request("Addres s") &
"'")
session("Return edScopeID") = objrs_dr.Fields ("SPReturnedID" )
%>
alert ( <%=session("Ret urnedScopeID")% );
...
}
I use Javascript to test the returned result. It always returns 100
instead of 101. Could you give me some suggestions?
Cheers
Bon
Ray Costanzo [MVP] 寫道:
Scrap the whole way you're doing this and used a stored procedure that
returns SCOPE_IDENTITY. And have the stored procedure handle the insert
instead of creating a recordset object the way you're doing. http://www.aspfaq.com/show.asp?id=2174
Ray at work
"Bon" <bo***********@ gmail.comwrote in message
news:11******** **************@ h48g2000cwc.goo glegroups.com.. .
Dear all
>
I have a javascript function which embeds ASP script for inserting data
into database. After the data is inserted database, I select the
maximum id (the latest inserted record id). But, it always select the
previous id. It seems the database hasn't been refreshed after inserta
new row.
>
my code is like
>
set objrs = server.createob ject("ADO.recor dset")
objrs.open "myTableNam e", objDBConnection
objrs.AddNew
objrs.Fields("F oreignID") = Request("foreig nid")
objrs.Fields("F irstName") = Request("firstn ame")
objrs.Fields("L astName") = Request("lastna me")
objrs.Fields("P hone") = Request("phone" )
objrs.update
objrs.close
objrs.open "select max("PrimaryID" ) from tbl_myTable", objDBConnection
>
No matter I use objrs.refresh or objrs.requery instead of objrs.close.
The database is not refreshed. How can I refresh the database after I
add a new row in it? Please give me some suggestions.
>
Cheers
Bon
>
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: droog |
last post by:
hi group!
I am new to PHP and so far managed to find my answers by searching
this group instead of posting repeating questions, but I don't know
what to search for to get answer to this question:
I want to sell pin numbers.
I have a script called display.php that gets a pin number from MySQL
database table, displays it in the browser and deletes the row it got
that pin from in the database table.
|
by: ZoombyWoof |
last post by:
Hi. I have a Framed page, and in the "main" frame a userchoise is made. In
my "top" frame I have a table containing some status info, the current
logged on user (the username is saved in a SESSION variable) and some
stuff like that. If I in the "main" frame change user (its a drop down
list with choices from a MySQL DB) I would like to reflect that in the
status row in the "top" frame. If I do a "header( Location blablabla )",
that page is...
|
by: Mark Feller |
last post by:
What are best practices to check to see if a .php script is called for the
first time versus a user hitting a refresh button on their browser?
I am playing around with a PHP front-end to a database. If the user enters
values in a form (form.html), hits submit, the PHP script (insert.php) puts
the submitted fields into the database as intended. insert.php displays a
success message if successful or an error message otherwise. If the...
|
by: Jeronimo Bertran |
last post by:
Hi,
I have a page with a very data intensive grid which needs to be
automatically refreshed constantly if a change is detected. In order to
not refresh the complete page so often, I created an iframe on my page
whose html has the refresh meta as follows :
<meta http-equiv="refresh" content="10">
The iframe is effectivelyh refreshed every 10 seconds without having the
|
by: Peter |
last post by:
1) I have a C# web application and what I am trying to do is create a popup window from a link on the parent window
2) the popup window will have a button and when a user clicks on the button the program should update a database, close the window and refresh the parent window.
My question is does anyone have a example of popup window wich will close it's self and refresh the parent window when a user clicks on a button?
I know there are...
| |
by: Mark |
last post by:
i'm using an html form to submit comments to a database. the form is on
the same page where the comments are being displayed. if you hit
submit, your comment appears as it should, but then if you hit refresh
there is a duplicate post. how might i fix this?
|
by: phforum |
last post by:
Hi,
I wrote a PHP page for user input the information to search the
database. And the database data will update every second. I want to
set the auto refresh to get the data from database every minute. But
the page always display the dialog box ask me to resend the
information. How to disable this warning message. I using POST and
REQUEST to get the data from user input page.
Thanks all
|
by: Ned Balzer |
last post by:
Hi all,
I posted this question some time ago in an earlier thread but so far I
still don't have an understanding of why this is happening or what I
can do to fix it.
I use Session variables, such as Session("username") to store a lot of
information about who is logged in to my app and what they can do.
Since the app permits certain users to impersonate other users (permits
some users to delegate their work to assistants, who are...
|
by: malcster2 |
last post by:
hello, i am a beginner to ajax.
i have created a mysql database, which i would like to access from a web page.
i have created 3 files, a html to display the data, a php file to extract the data, and a javascript file to to the clever stuff.
when i access the html page, all the data is displayed correcty, but if i add or delete any records, and press the button i have created to refresh the data(without reloading), the data doesn't change....
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |