can anyone help me about this error. "Invalid attempt to call metadata when reader is closed". Thnx in advance.
Public Sub DisplayCust(ByVal lv As ListView)
If cnSQL.State = ConnectionState.Open Then cnSQL.Close()
cnSQL.Open()
cmd = cnSQL.CreateCommand
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "sp_DisplayCust"
Dim param = New SqlClient.SqlParameter
param.ParameterName = "@cust_no"
param.SqlDbType = SqlDbType.VarChar
param.Value = lv.SelectedItems(0).Text
cmd.Parameters.Add(param)
objRead = cmd.ExecuteReader
Try
While objRead.Read()
With frmCustomer
.txtCustCode.Text = (objRead("cust_no") & "")
.cmbSM.Text = (objRead("sm_name") & "")
.txtCustname.Text = (objRead("cust_name") & "") < Error in this line
.txtaddress.Text = (objRead("address") & "")
.txtRemarks.Text = (objRead("remarks") & "")
.txtEmail.Text = (objRead("email_add") & "")
End With
End While
objRead.Close()
cnSQL.Close()
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "Data Error")
Exit Sub
End Try
End Sub