I am loading some information about the selected vendor using mysql query. I made a method with a List as return type, then created another method to assign values coming from a list. I am wondering if there is a better way of doing things.

P.S. The vendorCrud object is a database helper.

 private List<string> GetVendorInformation(string vendorId)
        crud vendorCrud = new crud();
        List<string> columnData = new List<string>();

        string query = String.Format("SELECT tin, email_add, fax_no, tel_no, contact.contact_person FROM lib_inv_vendor vendor " +
           "LEFT JOIN lib_inv_vendor_contact_person contact ON vendor.vendor_id = contact.vendor_id " +
           "WHERE vendor.vendor_id = {0} ORDER BY contact_default DESC LIMIT 1", vendorId);

        vendorCrud.load_data(query, Modules.connection.filesetupDB1, CommandType.Text);

        foreach (DataRow item in vendorCrud.table.Rows)

        return columnData;

    private void SetVendorInformation(List<string> colData)
        txtVendorTin.EditValue = colData[0];
        txtEmail.EditValue = colData[1];
        txtFaxNo.EditValue = colData[2];
        txtTelNo.EditValue = colData[3];
        txtAttention.EditValue = colData[4];

    private void txtSupplier_EditValueChanged(object sender, EventArgs e)
  • \$\begingroup\$ Welcome to Code Review! You haven't shown the definition of your table(s), without which it's hard to give a good review. I recommend you include these definitions (preferably as SQL statements, so that reviewers can reproduce your test environment). \$\endgroup\$ – Toby Speight Mar 27 '19 at 8:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.