2 Attachment(s)
Getting Alt + 0141 () in results
I built a phonebook app and a backend to for modifying entries. The problem occurs when I attempt to edit an existing entry I get the Alt box character in my listbox for the search, or my textbox for modifying. I've tried different combinations of multiline, singleline.
Thanks!
Re: Getting Alt + 0141 () in results
all fields in database set to nvar(255)
if relative.
Re: Getting Alt + 0141 () in results
I have noticed that the issue is caused by the Find function of the backend application. Upon new entry no issue, find after new insert and then there are all kinds of added spacing characters to the result from database in the single-line textbox. Although multiline textboxes do not show these characters they are still there.
:ehh:
Re: Getting Alt + 0141 () in results
Solved the problem by using regex.replace(string, "[ \t\r\n]", "")
vb Code:
Public Function updatevalue(ByVal value, ByVal txtvalue) As Boolean
Dim ra As Integer
Dim thatline As String = txtvalue.text.ToString
thatline = System.Text.RegularExpressions.Regex.Replace(thatline, "[ \t\r\n]", "")
Dim command = New SqlCommand("Update PhoneNumbers Set " & value & "='" & thatline & "' WHERE LastName = '" & TxtLastName.Text _
& "' AND Firstname = '" & TxtFirstName.Text & "'", sqlphonebook.con)
If sqlphonebook.con.State = ConnectionState.Closed Then
sqlphonebook.con.Open()
End If
ra = command.ExecuteNonQuery()
sqlphonebook.con.Close()
End Function
Public Function getvalue(ByVal field1, ByVal field2, ByVal put, ByVal sqlput) As Boolean
'Creating a read of the database
Dim results As New System.Text.StringBuilder
Dim thatline1 As String
Dim command1 As New SqlCommand("SELECT rtrim(" & sqlput & ") FROM PhoneNumbers WHERE LastName = '" & field1.Text.ToString & "' AND Firstname = '" & field2.Text.ToString & "'", sqlphonebook.con)
'MsgBox(field1.ToString + Environment.NewLine + columnname + Environment.NewLine + put.ToString + Environment.NewLine + sqlput + Environment.NewLine + Environment.NewLine + command1.ToString)
' AND PerformingDate = (SELECT MAX(PerformingDate) FROM leadlog WHERE LeadTitle = '" & field.Text & "'
If sqlphonebook.con.State = ConnectionState.Closed Then
sqlphonebook.con.Open()
End If
Dim r As IAsyncResult = command1.BeginExecuteReader
Dim reader As SqlDataReader = command1.EndExecuteReader(r)
While reader.Read
For i As Integer = 0 To reader.FieldCount - 1
results.Append(reader(i).ToString & vbTab)
Next
results.Append(Environment.NewLine + Environment.NewLine)
End While
reader.Close()
command1.Connection.Close()
thatline1 = results.ToString
thatline1 = System.Text.RegularExpressions.Regex.Replace(thatline1, "[ \t\r\n]", "")
put.Text = thatline1
End Function
Re: Getting Alt + 0141 () in results
Obvious error is obvious now...
vb Code:
Public Function updatevalue(ByVal value, ByVal txtvalue) As Boolean
Dim ra As Integer
Dim thatline As String = txtvalue.text.ToString
thatline = System.Text.RegularExpressions.Regex.Replace(thatline, "[ \t\r\n]", "")
Dim command = New SqlCommand("Update PhoneNumbers Set " & value & "='" & thatline & "' WHERE LastName = '" & TxtLastName.Text _
& "' AND Firstname = '" & TxtFirstName.Text & "'", sqlphonebook.con)
If sqlphonebook.con.State = ConnectionState.Closed Then
sqlphonebook.con.Open()
End If
ra = command.ExecuteNonQuery()
sqlphonebook.con.Close()
End Function
Public Function getvalue(ByVal field1, ByVal field2, ByVal put, ByVal sqlput) As Boolean
'Creating a read of the database
Dim results As New System.Text.StringBuilder
Dim thatline1 As String
Dim command1 As New SqlCommand("SELECT rtrim(" & sqlput & ") FROM PhoneNumbers WHERE LastName = '" & field1.Text.ToString & "' AND Firstname = '" & field2.Text.ToString & "'", sqlphonebook.con)
'MsgBox(field1.ToString + Environment.NewLine + columnname + Environment.NewLine + put.ToString + Environment.NewLine + sqlput + Environment.NewLine + Environment.NewLine + command1.ToString)
' AND PerformingDate = (SELECT MAX(PerformingDate) FROM leadlog WHERE LeadTitle = '" & field.Text & "'
If sqlphonebook.con.State = ConnectionState.Closed Then
sqlphonebook.con.Open()
End If
Dim r As IAsyncResult = command1.BeginExecuteReader
Dim reader As SqlDataReader = command1.EndExecuteReader(r)
While reader.Read
For i As Integer = 0 To reader.FieldCount - 1
results.Append(reader(i).ToString [B]& vbTab[/B])
Next
'---------->results.Append(Environment.NewLine + Environment.NewLine)
End While
reader.Close()
command1.Connection.Close()
thatline1 = results.ToString
thatline1 = System.Text.RegularExpressions.Regex.Replace(thatline1, "[ \t\r\n]", "")
put.Text = thatline1
End Function
[/QUOTE]