Re: leading spaces

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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
>
> %>
>


.



Relevant Pages

  • Re: leading spaces
    ... "Kevin Spencer" wrote: ... >>I have a connection to SQL Server and have setup a customer profile page ... >> update statement runs adds leading spaces to the database. ...
    (microsoft.public.frontpage.programming)
  • Idiomatic Expressions to Operating System Architecture: Transforming Rigids
    ... <Subject: Re: Idiomatic Expressions to Operating ... <endpoint during a single session * DATABASE + by ... <statements is a new feature of SQL Server 2005. ...
    (sci.math)
  • Re: MS Access DAO -> ADO.NET Migration
    ... William Vaughn ... Microsoft MVP ... Hitchhiker's Guide to Visual Studio and SQL Server ... My migration app works building a SSCE database file with imported data ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Cluster will not fail over.
    ... > As far as the TCP/IP issue goes, you had to rebuild the cluster and were ... > able to restore the master database. ... > a cluster installation you'll have to revisit. ... >> This worked bringing up the sql server in minimal mode. ...
    (microsoft.public.sqlserver.clustering)
  • Re: MS Access DAO -> ADO.NET Migration
    ... full SQL Server and I see the logic you explained in a multi user ... allow two users to access the same database file Read/Write at any given ... The book was a pleasure to read after the gibberish that Microsoft 'puts ... Hitchhiker's Guide to Visual Studio and SQL Server ...
    (microsoft.public.dotnet.framework.adonet)