Below is a code displaying records from a view which is concatenating first and surname in textbox on the form called accoutnholder. But the code "txtAccountHolder.Text = myDataReader.Item("First_Name&" - " &Surname")tostring]" show the expression does not produce value. please i need ur help to continue
Private Sub txt_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtLoan_no.LostFocus
Try
put = "SELECT * FROM Loan WHERE (Loan_no = @Loan_no)"
Dim mySqlDBConnection As New SqlConnection(ConnectionString)
Dim mySqlDBCommand As New SqlCommand(put, mySqlDBConnection)
mySqlDBCommand.Parameters.AddWithValue("@Loan_No", txtLoan_no.Text)
mySqlDBConnection.Open()
Using myDataReader As SqlDataReader = mySqlDBCommand.ExecuteReader
If myDataReader.Read() Then
txtAccountHolder.Text = myDataReader.Item("First_Name&" - " &Surname")tostring]
txtAccount_no.Text = myDataReader.Item("Account_no").ToString
msdDate_Applied.TextMaskFormat = myDataReader.Item("Date_Applied").ToDate
txtPrin_Amount.Text = myDataReader.Item("Prin_Amount").todouble
txtAccount_Name.Text = myDataReader.Item("Account_Name").ToString
Else
MessageBox.Show("Record Doesn't exit, add as new record")
End If
End Using
mySqlDBConnection.Close()
Catch ex As SqlException
MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error)
Catch err As System.Exception
MessageBox.Show(err.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub

Recommended Answers

All 2 Replies

txtAccountHolder.Text = myDataReader.Item("First_Name&" - " &Surname")tostring]

chage it with :

txtAccount_Name.Text = myDataReader.Item("First_Name").ToString & "-" & myDataReader.Item("Surname").ToString
commented: Nice +4
commented: fast.. +4

thanks you, it's working perfectly

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.