[thelist] Disappearing values when updating db [Access/Vbs/ASP]

Chris W. Parker cparker at swatgear.com
Fri May 3 12:49:01 CDT 2002


> Can we see some more relevant code (like the sub)?

oh yeah, good idea. ;)

here it is in it's entirety...

i reformatted it a little and also on the lines that start with +++
that's me adding comments to the code in the email.


==============
Sub setUpdateCustomer(sNewEmail, _
				sFirstName, _
				sMiddleInitial, _
				sLastName, _
				sCompany, _
				sAddress1, _
				sAddress2, _
				sCity, _
				sState, _
				sZip, _
				sCountry, _
				sPhone, _
				sFax, _
				bSubscribed)

	Dim sLocalSQl, rsUpdate, iOldNum
	Dim mySCompany

	sLocalSQL = "SELECT custFirstName, custMiddleInitial, " _
		& "custLastName, custCompany, custAddr1, " _
		& "custAddr2, custCity, custState, custZip, " _
		& "custCountry, custPhone, custFax, " _
		& "custTimesAccessed, custLastAccess, custEmail, " _
		& "custIsSubscribed " _
		& "FROM sfCustomers " _
		& "WHERE custID = " &
Trim(Request.Cookies("sfCustomer")("custID"))

	Set rsUpdate = Server.CreateObject("ADODB.RecordSet")

	rsUpdate.Open
sLocalSQL,cnn,adOpenDynamic,adLockOptimistic,adCmdText

	If NOT rsUpdate.EOF Then
		debugWrite("NOT rsUpdate.EOF")
		iOldNum = (rsUpdate.Fields("custTimesAccessed"))
		debugWrite("iOldNum = " & iOldNum)
		If iOldNum = "" Then
			iOldNum = 1
		Else
			iOldNum = cInt(iOldNum)
		End If

+++ debugWrite() is used to response.write values for debugging
+++ obviously. it is defined like this...
+++ Function debugWrite(toWrite)
+++   If(vDebug = 1) Then
+++     Response.Write(toWrite & "<br>")
+++   End If
+++ End Function
		debugWrite("sFirstName = " & sFirstName)
		rsUpdate.Fields("custFirstName")		=
sFirstName

		debugWrite("sMiddleInitial = " & sMiddleInitial)
		rsUpdate.Fields("custMiddleInitial")	= sMiddleInitial

		debugWrite("sLastName = " & sLastName)
		rsUpdate.Fields("custLastName")		= sLastName

		debugWrite("sCompany = " & sCompany)
+++ The line below is the line i was doing the testing on,
+++ and it is also the original line.
		rsUpdate.Fields("custCompany")		= sCompany

+++ If i do something like the line below, the value is
+++ inserted like it should be. This would be the same
+++ line as indicated above, but just a little different.
+++		rsUpdate.Fields("custCompany")		= "hello"
'sCompany

+++ I can also do this and it will work properly...
+++		sCompany = "hello"
+++		rsUpdate.Fields("custCompany")		= sCompany

		rsUpdate.Fields("custAddr1")			=
sAddress1
		rsUpdate.Fields("custAddr2")			=
sAddress2
		rsUpdate.Fields("custCity")			= sCity
		rsUpdate.Fields("custState")			= sState
		rsUpdate.Fields("custZip")			= sZip
		rsUpdate.Fields("custCountry")		= sCountry
		rsUpdate.Fields("custPhone")			= sPhone
		rsUpdate.Fields("custFax")			= sFax
		rsUpdate.Fields("custTimesAccessed")	= iOldNum + 1
		rsUpdate.Fields("custLastAccess")		= Date()
		If sNewEmail <> "" Then
			rsUpdate.Fields("custEmail")		=
sNewEmail
		End If
		If bSubscribed = "" Then
			rsUpdate.Fields("custIsSubscribed") = 0
		Else
			rsUpdate.Fields("custIsSubscribed") = 1
		End If
		rsUpdate.Update
	End If
	closeObj(rsUpdate)
End Sub
======================

i hope that helps you people see what's going on, or lack of what's
going on.

thanks,
chris.



More information about the thelist mailing list