Only getting first letter when reading data of SQL Serve

Only getting first letter when reading data of SQL Serve

Post by Andrew W » Fri, 16 Aug 2002 21:28:02



Hello,

This is a weird problem.  Am attempting to extract information of a database
and display it on a ASPX web page.  The information extracts ok but it seems
that not the whole word is displayed.  For example, when user logs in, the
main page should say, "Greetings Joe Bloggs", instead it says "Greetings J
B".  When in the database, the column for first name is in full "Joe" and
column for second name is "Bloggs".  Somehow it is only extracting the first
letter of the column.

Heres my stored procedure to retrieve customer details of the database.

----------------------------------------------------------------------------
---
ALTER PROCEDURE dbo.retrieveUserDetails
/*

AS









from customers

----------------------------------------------------------------------------
---

And here is the code for placing the extracted data from the server on to a
*.aspx page.

----------------------------------------------------------------------------
---

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
        UserSessionCheck(Session, Request.Cookies("EHome"))
        If Session("loginStatus") = 1 Then
            loggedInMsg.Text = "Wellcome, you are currently logged in as "
            With sqlProcRetrieveUserDetails

            ''Pass in customer ID to retrieve specified customer record


                sqlConnection.Open()
                .ExecuteNonQuery()
                sqlConnection.Close()

            ''Display retrieved information and put them in their respective
labels.



            End With
        Else
            firstName.Visible = False
            lastName.Visible = False
            loggedInMsg.Text = "You are currently logged in as guest."
        End If
End Sub

----------------------------------------------------------------------------
---

And here is the DB table design sheet.

----------------------------------------------------------------------------
---

Key:        Column Name:                        Data Type:        Length:
Allow Nulls:
3             CustomerID                             int
4                            0
0             CustomerFirstName                 varchar              50
1
0             CustomerLastName                 varchar              50
1
0             CustomerAddress                    varchar             150
1
0             CustomerCity                          varchar             100
1
0             CustomerPostCode                  varchar             15
1
0             CustomerCountry                     varchar             100
1
0             CustomerEmail                        varchar             150
1
0             CustomerUserName                 varchar             25
1
0             CustomerPassword                  varchar             25
        1
0             CustomerCookie                      tinyint               1
1

----------------------------------------------------------------------------
---

So customerFirstName would contain "Joe" and CustomerLastName would contain
"Bloggs".

But when runing the procedure, only the first letter of the columns are
displayed. E.g. "J " and "B ".  The last part of the letters it seems have
been hacked off, but why?

If anyone know what the problem is with this?

Thanks!

 
 
 

Only getting first letter when reading data of SQL Serve

Post by Keith Kratochvi » Fri, 16 Aug 2002 22:46:59


The first step that I would take is to run the stored procedure within Query
Analyzer.  Check the output variables.  If it returns the "missing" data
your problem is within the web page.  The stored procedure appears correct.

--
Keith, SQL Server MVP


> Hello,

> This is a weird problem.  Am attempting to extract information of a
database
> and display it on a ASPX web page.  The information extracts ok but it
seems
> that not the whole word is displayed.  For example, when user logs in, the
> main page should say, "Greetings Joe Bloggs", instead it says "Greetings J
> B".  When in the database, the column for first name is in full "Joe" and
> column for second name is "Bloggs".  Somehow it is only extracting the
first
> letter of the column.

> Heres my stored procedure to retrieve customer details of the database.

> --------------------------------------------------------------------------
--
> ---
> ALTER PROCEDURE dbo.retrieveUserDetails
> /*
> */










> AS









> from customers

> --------------------------------------------------------------------------
--
> ---

> And here is the code for placing the extracted data from the server on to
a
> *.aspx page.

> --------------------------------------------------------------------------
--
> ---

> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
>         UserSessionCheck(Session, Request.Cookies("EHome"))
>         If Session("loginStatus") = 1 Then
>             loggedInMsg.Text = "Wellcome, you are currently logged in as "
>             With sqlProcRetrieveUserDetails

>             ''Pass in customer ID to retrieve specified customer record


>                 sqlConnection.Open()
>                 .ExecuteNonQuery()
>                 sqlConnection.Close()

>             ''Display retrieved information and put them in their
respective
> labels.



>             End With
>         Else
>             firstName.Visible = False
>             lastName.Visible = False
>             loggedInMsg.Text = "You are currently logged in as guest."
>         End If
> End Sub

> --------------------------------------------------------------------------
--
> ---

> And here is the DB table design sheet.

> --------------------------------------------------------------------------
--
> ---

> Key:        Column Name:                        Data Type:        Length:
> Allow Nulls:
> 3             CustomerID                             int
> 4                            0
> 0             CustomerFirstName                 varchar              50
> 1
> 0             CustomerLastName                 varchar              50
> 1
> 0             CustomerAddress                    varchar             150
> 1
> 0             CustomerCity                          varchar
100
> 1
> 0             CustomerPostCode                  varchar             15
> 1
> 0             CustomerCountry                     varchar             100
> 1
> 0             CustomerEmail                        varchar             150
> 1
> 0             CustomerUserName                 varchar             25
> 1
> 0             CustomerPassword                  varchar             25
>         1
> 0             CustomerCookie                      tinyint               1
> 1

> --------------------------------------------------------------------------
--
> ---

> So customerFirstName would contain "Joe" and CustomerLastName would
contain
> "Bloggs".

> But when runing the procedure, only the first letter of the columns are
> displayed. E.g. "J " and "B ".  The last part of the letters it seems have
> been hacked off, but why?

> If anyone know what the problem is with this?

> Thanks!


 
 
 

1. Reading first letter of each word in a field

I have to make a report which lists patients names as:

Initial of first and middle name and the first two letters of the last name.

I have a field for last name and a field for first and middle name (first and
middle name in one field).  Is there a way to read these letters into another
table or another field.

Your help would be appreciated,
Francis

2. How to Select off of the results of a Stored Proc

3. Changing first letter to a Capital Letter

4. 2,5 Gbyte of SGA and 400 tables

5. Printing by first letter of first word

6. Looking for a good tutorial that deals with the JOINS,ROLLUP

7. First letter uppercase, rest lower function???

8. Logical Logs

9. Trigger autocorrect first letter

10. First letter search

11. Capitalize first letter

12. Capitalizing first letters of all the words.

13. Help converting a field to First letter capitalized only