Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Handling Special Characters in Text fields

Status
Not open for further replies.

mwa

Programmer
Jul 12, 2002
507
US
I have an asp.net web application that reads/writes data to a DB2 database. We have been logging numerous "Conversion Errors" in our error tracking utility. I've finally been able to narrow the problem down to users entering text containing the ’ character (or char(146))... Not to be confused with the ' character (or char(39)). DB2 does not seem to like char(146) and errors out. I can do a replace on the field to deal with that character, but I'm trying to figure how that character is actually typed by the user? Any thoughts?

Thanks in advance,

mwa
<><
 
this is an ADO.Net/database issue, not webforms.
Are you using a parameterized query? if not this could be the problem. otherwise the parameters should automatically handle the "special" character. after that it's a database issue. forum178 would be a better place to start.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
faq732-7259
 
Yes, I am using a parameterized query:
Code:
Public Function InsertEmployment(ByVal strEmpId As String, ByVal strExpBucket As String, _
                                        ByVal strOldExpBucket As String, ByVal strFromDate As String, _
                                        ByVal strOldFromDate As String, ByVal strToDate As String, _
                                        ByVal strCompanyName As String, ByVal strResponsibilities As String) As Int32

            Dim myDB2Connection As New iDB2Connection(ConfigurationSettings.AppSettings("DB2ConnectionString"))
            Dim cmdInsert As New iDB2Command("TRMSPSQL.PER0202P11_INS_EXP_REC", myDB2Connection)
            cmdInsert.CommandType = CommandType.StoredProcedure

            cmdInsert.Parameters.Add(New iDB2Parameter("P_EMP_ID", strEmpId))
            cmdInsert.Parameters.Add(New iDB2Parameter("P_EXP_BUCKET", strExpBucket))
            cmdInsert.Parameters.Add(New iDB2Parameter("P_OLD_EXP_BUCKET", strOldExpBucket))
            cmdInsert.Parameters.Add(New iDB2Parameter("P_FROM_DATE", strFromDate))
            cmdInsert.Parameters.Add(New iDB2Parameter("P_OLD_FROM_DATE", strOldFromDate))
            cmdInsert.Parameters.Add(New iDB2Parameter("P_TO_DATE", strToDate))
            cmdInsert.Parameters.Add(New iDB2Parameter("P_COMPANY_NAME", strCompanyName))
            cmdInsert.Parameters.Add(New iDB2Parameter("P_RESPONSIBILITIES", strResponsibilities))
            

            myDB2Connection.Open()
            Dim dr As iDB2DataReader = cmdInsert.ExecuteReader(CommandBehavior.CloseConnection)
            Dim intRecordsAffected As Int32
            If dr.HasRows() Then
                While dr.Read()
                    intRecordsAffected = dr(0)
                End While
            End If
            dr = Nothing
            Return intRecordsAffected
            closeDB2(myDB2Connection)
        End Function

I would thought the special char would have been handled as well. I'll check the DB2 forum and see if they can provide any assistance.

mwa
<><
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top