Using information from a database??

Hi,

I have just started an application that will need access to a database( in this case an Access database).
I'm very new to Vb and access for that matter, Before I really get started I was wondering a couple of things.

1. I have added a field from my database to my form which in this case displays names, is it possible to use what ever value is in the textbox in your program code. i.e i have added another textbox(not connected to my database) and would like it to output certain words depending on the name displayed in the text box from the database..
Is this possible

2. My ultimate aim for my application is for the user to be able to decide what information they want to see from my database. i.e one time they may want to see the top 10 times they achieved for an event, the next time tey may want to see top 20 but maybe with an additional column of information. Is this feasible, or would I have to add all possible combinations of data to my forms during the design stage

any help or advise on this would be great

thanks

lee


Answer this question

Using information from a database??

  • byteguy

    thanks cgraus,

    I have been through the Microsoft visula studio 2005 step by step, which was great, however these books tend to cover the basics of most topics, it doesn't cover working with databases in much depth, so now I have to try and learn as I go. Plus as that book was £28 I can't really afford to buy another one just yet.

    Hence asking for help from this forum as I go

    thanks

    lee


  • Zuuljin

    G'day Lee

    What you're asking in question 1 is possible, I suppose it depends upon how many names you have in your database for starters, but I'm not sure if it's practicable.

    If I'm following you correctly, you're taking a name from a database which will be displayed in a textbox on your form. Then depending upon that name you will be displaying some secondary data in a second textbox. You say that this textbox will not be connected to the database. So this means that you will have to create a list within your program that contains all of the names and the secondary data. If the secondary data is simply the number of characters in the name or whether or not the name starts with a particular character then thats not a problem. I suppose it really depends upon how complex the secondary data is.

    Personally I would create that field in the database, and then display that in the second textbox.

    If your list of names is small and the secondary data is not going to alter then you could use an arraylist. Bind the names to a listbox, and depending upon the name picked display your other information. But as I said this would only work if the list of names is quite short.

    As to question 2. Again this is possible, but I think that you have seen yourself that this is going to be more complex. They may want to see the top ten books by author, or title and you would have to account for this in your program.

    Hope you work it out.

    Graham.


  • Mike_A139353

    OK - it's time to drill a little deeper. A textbox has no idea where it's text came from, there's no reason why having it databound would change your ability to access it.

    First of all, do you have a textbox called textbox1 Secondly, are they both on the same form Third, when you say 'it doesn't work', what's the error that you're getting. This is the most critical point, if your question had not seemed trivial I would have asked this to start with - error messages are the number one thing you should be posting when you ask for help, they tell me more about what's going on that just about anything else you could offer.



  • snibbets

    So how do I get the text from the textbox containg the database info into the textbox I have added to the form
    I have tried the following
    "where firstnametextbox is name of textbox with database name in it, and textbox1 is a normal textbox"
    textbox1.text = firstnametextbox
    my.textbox1.text = firstnametextbox
    me.textbox1.text = firstnametextbox
    textbox1.text = my.firstnametextbox
    textbox1.text = me.firstnametextbox

    i've also tried
    dim name as string = firstnametextbox
    textbox1.text = name

    none of these work....
    please help!!!!!!

  • netbug

    I'm still very new to VB and trying to learn (a steep learning curve that is)

    Not wanting to be rude, but a lot of people find the learning curve steep because few seem willing to learn the language before trying to write functional programs with it. When I taught myself C++, I bought a book and worked through it before I even considered creating a form, let alone talking to a database. I still believe this is the best approach, but assuming I won't be able to disuade you from your current path...

    However this is not ideal I want it to appear automatically, am I missing something really obvious I don't want to have to type in a textbox for my information to appear.

    I have no idea why this would happen. If you set the Text property, it should display right away. Calling Invalidate() will refresh your form, but should definately not be necessary.



  • weke

    hi

    sorry..I'm still very new to VB and trying to learn (a steep learning curve that is)
    it does appear to be working now. when I ran the program the textbox1 was just blank so I assumed it wasn't working (no error message), however I have just tried again and found that when I place my cursor in the textbox1 and begin to type the name appears that I want i.e from the database textbox.

    However this is not ideal I want it to appear automatically, am I missing something really obvious I don't want to have to type in a textbox for my information to appear.

    thanks
    lee

  • Holzberg

    1. myTextBox.Text contains the text typed into the text box

    2. you can make these sort of things possible, by allowing the user to select what columns they want displayed, and how many. SQL Server 2005 is the first to allow a variable in a TOP statement, I don't know how Access goes in this department, or if you'd need to do it in code, or use dynamically generated SQL.



  • scjconsulting

    i've also tried
    dim name as string = firstnametextbox
    textbox1.text = name

    Gosh, I would have thought VB.NET would handle this. However, in every case, just as textbox1 has a .Text property, so too does firstnametextbox.

    textbox1.text = firstnametextbox.text



  • pater

    hi

    sorry I missed the .text off the end,
    however it still doesn't work.

    Is it possible to get information form text boxes that has come from a database /

    I really hope so, if not I'm wasting my time and I might aswell just use access and forget about VB...

    lee

  • Using information from a database??