473,884 Members | 2,313 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem in Adding record in Database

2 New Member
Hi dears,

I am adding a record in Access database using AddNew method of recordset. here is the code of the page ..
Expand|Select|Wrap|Line Numbers
  1. <%
  2.         Set RsLibBuild = Server.CreateObject ("ADODB.Recordset")
  3.         RsLibBuild.ActiveConnection = conn
  4.         RsLibBuild.LockType = 2
  5.         RsLibBuild.CursorType = 1
  6.  
  7.         RsLibBuild.Open "select * from tblbuilding where building_name='" & request.Form ("buildingname") & "' and area_name='" &  request.Form ("areaname") & "' and city_name='" & request.Form ("cityname") & "' and lib_status='1'"
  8.  
  9.             if RsLibBuild.EOF or RsLibBuild.BOF then
  10.  
  11.  
  12.                 RsLibBuild.AddNew
  13.                 RsLibBuild ("building_name") = Request.Form ("buildingname")
  14.                 RsLibBuild ("area_name") = Request.Form ("areaname")
  15.                 RsLibBuild ("city_name") = Request.Form ("cityname")
  16.                 RsLibBuild ("description") = Request.Form ("thecontent")
  17.                 RsLibBuild ("lib_status") = "1"
  18.                 RsLibBuild ("dated") = date
  19.                 RsLibBuild ("timed") = time
  20.                 RsLibBuild ("logby") = session("uname")
  21.                 RsLibBuild.Update                
  22.  
  23.                 RsLibBuild.Close
  24.                 set RsLibBuild = nothing
  25.  
  26.                 Msg = "1 Record Added .... "
  27.                 Response.Redirect "buildingsnap.asp?id="& request.Form("buildingname") &"&ConfMsg="&Msg
  28.  
  29.             else
  30.  
  31.                 RsLibBuild.Close
  32.                 set RsLibBuild = nothing
  33.  
  34.                 Msg = "Record already exists ....  "
  35.                 Response.Redirect "addlibbuilding.asp?ErrMsg="&Msg
  36.  
  37.  
  38.             end if
  39.  
  40.  
  41. %>
In ideal scenrio of database entry the page shud be redirected to buildingsnap.as p with Msg "1 Record Added..." but its happening reverse and data is being added in the database but after RsBuilding.upda te it goes to the else part and redirect to addlibbuilding. asp with Msg "Record Already Exist".

Record is being added but redirection of page is wrong. If i comment the RsBuilding.upda te line in above mentioned code then it works fine and redirect propery.

A quick response will be highly appreciated..

Thanx in adv.

Raaaz
Sep 19 '07 #1
1 1465
jhardman
3,406 Recognized Expert Specialist
You definitely wrote this code correctly. In any given time through this script it will not go through both the if and the else clause, so it must be going through this script twice from what you've told us. I would guess that perhaps buildingsnap.as p is redirecting back here, that would explain why you go into the else clause.

Jared
Sep 20 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
2258
by: VIJAY KUMAR | last post by:
Hi pals, I am using 2 web forms (pages). In first page, i have Datagrid control and on second page i have a hyper link control to the first page and Add value to the data grid/Database. Problem: when I click on the hyperlink on the second page, i am getting the first page with cahed data. But i didn't declare/Use code for cache data. when i
2
2090
by: Douglas Buchanan | last post by:
This is a mystery! Why does the boolean value of a record change without my input. What follows describes the situation and the behavior. Table1: Field1: Text Field2: Yes/No Form1 has two subforms. Toggle1 selects Subform2
7
2259
by: RC | last post by:
When I am adding records to a database and each record is unique by the Serial Number. I would like to step through my code adding records unless the Serial Number already exists in the database. If the record already exits, then I would like to pop up a form, in pop-up, dialog mode. The form will ask if the user wants to make changes to the existing record and go back to the form and not make any changes. The code stops because the...
1
2086
by: Terry | last post by:
Hello, Has anyone experienced the following problem following an Upsize from Access 97 to SQL 2000 using the MS Upsize Wizard? Or can anyone see what the problem might be. Before Upsize (Access 97 front end and Access 97 tables): A MainForm loads up correctly and then I enter a ReferenceNumber value in a MainForm field control. I then click on the first field of a SubForm, the ReferenceNumber then shows at the top of the SubForm and...
6
3822
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length is more that 1249 bytes, then the progress bar of the browser will move too slow and then displaying that the page not found!!!! If the message is less than or equal to 1249 then no problem.
9
9727
by: Ecohouse | last post by:
I have a main form with two subforms. The first subform has the child link to the main form identity key. subform1 - Master Field: SK Child Field: TrainingMasterSK The second subform has a master-child link to the first subform. subform2 - Master Field: subTrainingModule.Form!TrainingModuleTopicSK Child Field: TrainingModuleTopicSK
9
5768
by: HC | last post by:
Hello, all, I started out thinking my problems were elsewhere but as I have worked through this I have isolated my problem, currently, as a difference between MSDE and SQL Express 2005 (I'll just call it Express for simplicity). I have, to try to simplify things, put the exact same DB on two systems, one running MSDE and one running Express. Both have 2 Ghz processors (one Intel, one AMD), both have a decent amount of RAM (Intel system...
10
2240
by: AdrianGawrys | last post by:
Hi guys, I recently rewrote onClick procedure for Calendar on my form (frmRota). It opens record from tblRotas where field rDate is equal the one selected on Calendar. If such a record doesnt exist I want it to be created. Before only way to create new record was to click on NewRecord button that I created using Access2003 button wizard. Calendar is not bound to any field in recordsource but on this form I have text box rDate that is bound to...
1
1779
by: Kyosuke18 | last post by:
Hi everyone, I have a problem in deleting a data that is connected on the database.. I tried this code but it shows me an error: Run-time error '-2147217900(80040e14)': Syntax error in string in query expression 'ID=". Here is the code that i did: Dim cn As New ADODB.Connection Dim rs As New ADODB.Recordset Dim ab As String cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Administrator\My...
0
11167
Oralloy
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...
0
10768
jinu1996
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...
1
10868
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,...
0
10422
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9591
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7984
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5808
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...
0
6009
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4623
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.