Load data from sql in Array

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • asmx126453
    New Member
    • Sep 2008
    • 72

    Load data from sql in Array

    Hey guys i need help with loading an value from a SQL database record

    Its like this i have a database with a table in it and in all those table are records and i know you can load 1 reccord value from a reccord into an array

    and i now its it done a litle bit like this

    .......Array[0] so that with this bit af code he loads the first record from the database into the array .......

    ......Array[1] and like this reccord number 2 i know this is posible in C# i just cant get it to work cud somone pleas post the code with how i can load a reccord value into an array with a number behingd it so he know wich record to put in the array

    Tnx for your help
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Show us what you tried first.
    P.S Also read about a neat trick called data binding. It allows you to achieve all that without breaking any bones.

    Comment

    • Curtis Rutland
      Recognized Expert Specialist
      • Apr 2008
      • 3264

      #3
      I'm not sure what your goal is, it was a bit hard to understand...bu t we have two articles that might help you in using a database:

      Comment

      • asmx126453
        New Member
        • Sep 2008
        • 72

        #4
        Il try to explain it again i have a databse in sql like this for example

        Firstname Lastname Age

        Jan Jansen 44
        0 1 2

        now i have 3 records with a number on it in sql starts with 0 so it looks like this record 0 is Firstname and so on

        now i whanne load the name Jan into an Array someting like this
        Code:
        txtFirstname.Text = OfferteArray[0];
        txtLastname.Text = OfferteArray[1];
        txtAge.Text = OfferteArray[2]
        so i whant that the OfferteArray[0] has loaded the value Jan from my database and strored it in the txtbox txtFirstname.Te xt

        Hope you understand me now Tnx for reply
        Last edited by asmx126453; Nov 20 '08, 02:34 PM. Reason: kaming it look better

        Comment

        • r035198x
          MVP
          • Sep 2006
          • 13225

          #5
          That OfferteArray again! I'm out of this thread.

          Comment

          • asmx126453
            New Member
            • Sep 2008
            • 72

            #6
            Haha Tnx for your help man

            Comment

            • r035198x
              MVP
              • Sep 2006
              • 13225

              #7
              OK. One last time.

              What you are trying to do with those arrays all over the place is very Fortranesque.
              Better use object oriented programming these days. Simply create a small class that represents your table structure. You then read data row by row creating objects of that class type with the data and store those objects in ONE ArrayList where you can then manipulate them at your own leisure.

              P.S Several useful hints have already been given to you for your problem but you seem to be ignoring them and starting off multiple threads for the same problem.

              P.P.S Remember that double posting is not allowed in these forums.

              P.P.P.S: this is really the last time!

              Comment

              • balabaster
                Recognized Expert Contributor
                • Mar 2007
                • 798

                #8
                Originally posted by r035198x
                OK. One last time.

                What you are trying to do with those arrays all over the place is very Fortranesque.
                Better use object oriented programming these days. Simply create a small class that represents your table structure. You then read data row by row creating objects of that class type with the data and store those objects in ONE ArrayList where you can then manipulate them at your own leisure.

                P.S Several useful hints have already been given to you for your problem but you seem to be ignoring them and starting off multiple threads for the same problem.

                P.P.S Remember that double posting is not allowed in these forums.

                P.P.P.S: this is really the last time!
                P.P.P.P.S: And he really means it this time...

                Comment

                • asmx126453
                  New Member
                  • Sep 2008
                  • 72

                  #9
                  Step Farther

                  Just for addition info i am not just reading your posts (i dont ignore your hints)i try to use them in my code if i can but i am not superp in english as i think you see in more of my posts so i somethimes have trouble knowing what evry word means and i am gratful your trying to help me but there were differnt errors on the post i posted before but i whont open a new post ont this bit of code anymore just hope you whanne help me with this new error on the same code

                  Hey i think i got 1 step farther becase now i get an differnt error and if i leave the txt OfferteArray in the code he will still runn the application but i get an error later on in a method

                  Dont now if you still whanne try to help but i need to try i cant do it myself XD

                  the error message i get now is

                  No overload for method 'GetOfferteGege vens' takes '1' arguments

                  And yes i first lookd on the internet for solutions but cudent find any useful 1
                  Weird thing is that the error message is differtn from the code error becase the bleu line is under dbConn

                  here is the code hope somone is interested enouf to try to help

                  Code:
                          #region Invullen van de tekstvelden uit Database
                          public void Vullen_tekstvelden(string[] OfferteArray, bool nieuw)
                          {
                              localhost1.dbConnection dbConn = new localhost1.dbConnection();
                              OfferteArray = dbConn.GetOfferteGegevens(txtNoteID.Text);
                              txtNoteID.Text = OfferteArray[0];
                              txtBTW.Text = "25";
                              txtOfferteNr.Text = OfferteArray[1];
                              txtDatum.Text = Functions.DateToNL(OfferteArray[2]);
                              txtDebNr.Text = OfferteArray[3];
                              txtKlantNaam.Text = OfferteArray[4];
                              txtContactpersoon.Text = OfferteArray[5];
                              txtOmschrijving.Text = OfferteArray[6];
                              txtOrderNr.Text = OfferteArray[7];
                  error is rule number 5 i think on the dbConn.GetOffer teGegevens lap of code

                  Comment

                  Working...