Results 1 to 2 of 2

Thread: Avoid Repetation of Data

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2020

    Avoid Repetation of Data

    Doubt in loading data to the combobox.

    Now I am loading data into the combobox using this function.

    CMD = New SqlCommand("select name from table1 ", CON)


    If DR.HasRows Then

    While DR.Read()


    End While



    End If


    The above code is working fine.
    But the doubt is how to define this function as a common function, & to use in different pages without writing the same codings in all pages

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Sydney, Australia

    Re: Avoid Repetation of Data

    Firstly, that code is definitely not working fine. That code wouldn't even compile. You might try copying and pasting code if at all possible and, if not, be a bit more careful reproducing it. It probably doesn't matter in this case but it might be critical on other occasions.

    As for your question, you do as you should always do in such situations. You declare a method and copy the code in, then you replace all the parts that are specific with parameters, so you can pass their values in as arguments each time you call it. Give it a go and see what you come up with. If you have an issue, post back with the actual code and description of the specific issue.
    Last edited by jmcilhinney; Feb 12th, 2020 at 06:28 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts


Click Here to Expand Forum to Full Width