| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 %> |
|
#2
|
||||
|
||||
|
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 |
|
#3
|
||||
|
||||
|
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>")
%>
Try the IsNull() function instead MK Last edited by selwonk : September 20th, 2004 at 12:38 PM. |
|
#4
|
||||
|
||||
|
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
%>
Empty Not empty Empty MK |
![]() |
| Viewing: ASP Free Forums > Programming > Code Bank > Passing Value to SQL |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|