473,569 Members | 2,729 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 1456
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
2242
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....
2
2076
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
2239
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...
1
2058
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...
6
3790
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...
9
9674
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
5746
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...
10
2220
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...
1
1712
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...
0
8119
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...
1
7668
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...
0
7964
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...
0
6281
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...
1
5509
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...
0
5218
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
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...
1
2111
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
0
936
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.