Code Bank
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingCode Bank

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old September 20th, 2004, 11:55 AM
ksd ksd is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 1 ksd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Passing Value to SQL

I have two buttons that should pass either a 0 or 1 value to SQL table names PO, column WebAnswer, when user clicks on either button from a web page. The user clicks on the buttons and is successful in being redirected to the "successful submit" page, but the value remains NULL in SQL table. There are no errors.
Can anyone see a problem with the code? Thanks!
<%
Option Explicit
dim rsPO
dim rsPOResponse
Dim Conn


set Conn=Server.CreateObject("ADODB.Connection") 'create Server Database Connection Object
set rsPO = server.CreateObject("ADODB.Recordset") 'create RecordSet Conn Obj
set rsPOResponse = Server.CreateObject("ADODB.Recordset") 'create RecordSet Conn Obj
Conn.open "Driver={SQL Server}; Server=Server Name;Database=DBName;UID=ID;PWD=Password;"

set rsPO = conn.Execute("SELECT Request_ID, " _
& " PurchasingAgent, Terms, Quantity, Description,Comments, UnitCostV ,LineTotalV, ShippingV, TotalV, Quantity2, Description2,UnitCost2V, LineTotal2V, " _
& " Dateadd(mi,((Create_Date-(7*60*60))/60.0),'Jan 1 1970 12:00AM')as Create_Date, " _
& " Quantity3, Description3,UnitCost3V, LineTotal3V, " _
& " Quantity4, Description4,UnitCost4V, LineTotal4V " _
& " FROM PO" _
& " where Request_ID='" & request.querystring("PONumber") & "'")

If not IsEmpty(request.Form("Approve")) then
set rsPOResponse = conn.Execute("Update PO SET WebAnswer = 1 "_
& "where (Request_Id='" & request.querystring("PONumber") & "')")
Response.Redirect("POsubmit_successful.asp")
end if
If not IsEmpty(request.Form("Disapprove")) then
set rsPOResponse = conn.Execute("Update PO SET WebAnswer = 0 "_
& "where (Request_Id='" & request.querystring("PONumber") & "')")

Response.Redirect("POsubmit_successful.asp")
end if

%>

Reply With Quote
  #2  
Old September 20th, 2004, 12:31 PM
selwonk's Avatar
selwonk selwonk is offline
Contributing User
ASP Free Frequenter (2500 - 2999 posts)
 
Join Date: Jun 2004
Posts: 2,942 selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 6 Days 9 h 49 m 28 sec
Reputation Power: 62
Hi

Try changing Response.Redirect to a Response.End in each IF statement and perform a Response.Write to confirm that the "not IsEmpty" logic is working correctly

MK

Reply With Quote
  #3  
Old September 20th, 2004, 12:35 PM
selwonk's Avatar
selwonk selwonk is offline
Contributing User
ASP Free Frequenter (2500 - 2999 posts)
 
Join Date: Jun 2004
Posts: 2,942 selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 6 Days 9 h 49 m 28 sec
Reputation Power: 62
Ok

I don't think IsEmpty() does what you think. Consider the following:
Code:
<%
 str_Value1 = Null
 str_Value2 = "Full"
 str_Value3 = ""
%>
<%
 If NOT IsEmpty(str_Value1) Then Response.Write("Not empty<br>")
 If NOT IsEmpty(str_Value2) Then Response.Write("Not empty<br>")
 If NOT IsEmpty(str_Value3) Then Response.Write("Not empty<br>")
%>
Each variable is considered to be "full" because a value has been assigned to the variable even if it is just Null

Try the IsNull() function instead

MK

Last edited by selwonk : September 20th, 2004 at 12:38 PM.

Reply With Quote
  #4  
Old September 20th, 2004, 12:42 PM
selwonk's Avatar
selwonk selwonk is offline
Contributing User
ASP Free Frequenter (2500 - 2999 posts)
 
Join Date: Jun 2004
Posts: 2,942 selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level)selwonk User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 6 Days 9 h 49 m 28 sec
Reputation Power: 62
Ok - this little function should do the trick:
Code:
<%
Function CustomIsEmpty(str_Value)
If IsNull(str_Value) OR str_Value = "" OR IsEmpty(str_Value) Then 
CustomIsEmpty = True
Else
CustomIsEmpty = False
End If
End Function
%>
<%
str_Value1 = Null
str_Value2 = "Full"
str_Value3 = ""
%>
<%
If NOT CustomIsEmpty(str_Value1) Then Response.Write("Not empty<br>") Else Response.Write("Empty<br>") End If
If NOT CustomIsEmpty(str_Value2) Then Response.Write("Not empty<br>") Else Response.Write("Empty<br>") End If
If NOT CustomIsEmpty(str_Value3) Then Response.Write("Not empty<br>") Else Response.Write("Empty<br>") End If
%>
This will return:

Empty
Not empty
Empty

MK

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingCode Bank > Passing Value to SQL


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT