Re: leading spaces
- From: "Kevin Spencer" <kevin@xxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 23 Sep 2005 17:58:52 -0400
Hi Jerry,
You're trimming alright, but adding a space back in. Example:
"Tenant = ' " & fixQuotes(Trim(Request.form("Tenantname"))) & "', "
Note the space after the single quote, right after "Tenant ="
As for nulls, you shouldn't be having any problems with that. An empty text
box has a value of "", which is an empty string, not null. If you're having
a problem there, it lies in something I don't see. You might want to check
your rules in the database.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
I'd rather be a hammer than a nail.
"Jerry" <Jerry@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:C66053C4-20F7-4EDA-A94A-CCB14B77EAC9@xxxxxxxxxxxxxxxx
>I have a connection to SQL Server and have setup a customer profile page
> where the customer can change their information. All the fields when the
> SQL
> update statement runs adds leading spaces to the database. I have used the
> Trim() function and it works in the textboxes but stores the extra space.
> Also, I have an Address2 line which in some cases are null and receive a
> error message. Your help would be greatly appreciated.
>
> Sample Code:
> Function fixQuotes(theString)
> fixQuotes = Replace(theString, "'","''")
> End Function
> strSql = "Update Tenant Set " &_
> "Tenant = ' " & fixQuotes(Trim(Request.form("Tenantname"))) & "', " &_
> "Address1 = ' " & fixQuotes(Trim(Request.form("Address1"))) & "', " &_
> "Address2 = ' " & fixQuotes(Trim(Request.form("Address2"))) & "', " &_
> "City = ' " & fixQuotes(Trim(Request.form("City"))) & "', " &_
> "State = ' " & fixQuotes(Trim(Request.form("State"))) & "', " &_
> "Zip = ' " & fixQuotes(Trim(Request.form("Zip"))) & "', " &_
> "PhoneNumber = ' " & fixQuotes(Trim(Request.form("PhoneNumber"))) & "', "
> &_
> "Email = ' " & fixQuotes(Trim(Request.form("email"))) & "', " &_
> "Password = ' " & Trim(fixQuotes( Pass )) & "'" &_
> "WHERE tenant.Customerid = '" & Cstr(Request.form("customer")) & "' "
>
> set conn=Server.createObject("ADODB.connection")
> conn.Open "DSN=Falco; uid=sa; pwd=6stang7"
> conn.Execute strSql
> conn.close
> set conn = nothing
>
> %>
>
.
- Follow-Ups:
- Re: leading spaces
- From: Jerry
- Re: leading spaces
- From: Jerry
- Re: leading spaces
- Prev by Date: computer name
- Next by Date: Re: computer name
- Previous by thread: computer name
- Next by thread: Re: leading spaces
- Index(es):
Relevant Pages
|