locked
VbProperCase won't convert items from Sqldatareader RRS feed

  • Question

  • User-1767698477 posted

    I have tried this several ways, and for some reason the values which are returned correctly from the 72k row database are uppercase. The vbpropercase is not working. Are the values retured from the reader strings? I tried to convert to string to insure StrConv works but it had no affect.

     Protected Sub btngetcounty_Click(sender As Object, e As EventArgs) Handles btngetcounty.Click
            Dim cn As New SqlConnection(ConfigurationManager.ConnectionStrings("sqlConnectionString").ConnectionString)
            Dim selectquery As String = "select City, County from [USZipCodes] where ZipCode =@Zipcode"
            Dim cmdselect As New SqlCommand(selectquery, cn)
            cmdselect.Parameters.Add(New SqlParameter("@Zipcode", Txtpropertyzip.Text))
            cmdselect.CommandType = System.Data.CommandType.Text
            cmdselect.Connection = cn
            cn.Open()
            Dim City As String = ""
            Using reader = cmdselect.ExecuteReader()
                While reader.Read()
                    City = reader.GetString(0).ToString
                    StrConv(City, vbProperCase)
                    txtpropertycity.Text = City
                    txtpropertycounty.Text = reader.GetString(1).ToString
                    StrConv(txtpropertycounty.Text, vbProperCase)
                End While
            End Using
            cn.Close()
        End Sub

    Saturday, May 29, 2021 4:47 PM

Answers

  • User-158764254 posted

    StrConv is a function that returns the result of the conversion.

    as in:

    City = StrConv(City, vbProperCase)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, May 29, 2021 5:17 PM

All replies

  • User-158764254 posted

    StrConv is a function that returns the result of the conversion.

    as in:

    City = StrConv(City, vbProperCase)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, May 29, 2021 5:17 PM
  • User-1767698477 posted

    Right...

    This is working! I wasn't quite doing all the assignments..

     Protected Sub btngetcounty_Click(sender As Object, e As EventArgs) Handles btngetcounty.Click
            Dim cn As New SqlConnection(ConfigurationManager.ConnectionStrings("sqlConnectionString").ConnectionString)
            Dim selectquery As String = "select City, County from [USZipCodes] where ZipCode =@Zipcode"
            Dim cmdselect As New SqlCommand(selectquery, cn)
            cmdselect.Parameters.Add(New SqlParameter("@Zipcode", Txtpropertyzip.Text))
            cmdselect.CommandType = System.Data.CommandType.Text
            cmdselect.Connection = cn
            cn.Open()
            Dim City As String = ""
            Dim County As String = ""
            Using reader = cmdselect.ExecuteReader()
                While reader.Read()
                    City = reader.GetString(0)
                    City = StrConv(City, vbProperCase)
                    txtpropertycity.Text = City
                    County = reader.GetString(1)
                    County = StrConv(County, vbProperCase)
                    txtpropertycounty.Text = County
                End While
            End Using
            cn.Close()
        End Sub
    End Class

    Saturday, May 29, 2021 5:33 PM