?
Solved

ADO, select two columns from an SQL statement and store as variables

Posted on 2005-05-11
5
Medium Priority
?
215 Views
Last Modified: 2010-04-23
Hello,

Currently i am using ADO to select the information ffrom one record and store that result into a variable (Sire).  what i would like to do is select two columns from that same sql statement and store the results in two diffrent variables.  here is the section of code that handles one variable right now....


        'Retrive sire code from the female that needs to be placed and stores it into the "Sire" variable
        SQL = "SELECT Sire FROM Females WHERE Wingband =" & WingbandInput.Text & ";"
        rsT.Open(SQL, conn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockUnspecified)
        Sire = rsT.GetString
        Sirelbl.Text = Sire
        Wingbandlbl.Text = WingbandInput.Text
        rsT.Close()


The problem is the "rsT.GetString" line will take all the results into a string, i want something like this with the two spots i left blank filled in.

        'Retrive sire code from the female that needs to be placed and stores it into the "Sire" variable
        SQL = "SELECT Sire, Pen FROM Females WHERE Wingband =" & WingbandInput.Text & ";"
        rsT.Open(SQL, conn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockUnspecified)
        Pen =
        Sire =
        Sirelbl.Text = Sire
        Wingbandlbl.Text = WingbandInput.Text
        rsT.Close()

Thanks!

-Navicerts
0
Comment
Question by:Navicerts
  • 3
  • 2
5 Comments
 
LVL 44

Accepted Solution

by:
Arthur_Wood earned 2000 total points
ID: 13976984
try this:

 SQL = "SELECT Sire, Pen FROM Females WHERE Wingband =" & WingbandInput.Text & ";"
        rsT.Open(SQL, conn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockUnspecified)
        Pen = rsT.Fields(0).Value
        Sire = rsT.Fields(1).Value
        Sirelbl.Text = Sire
        Wingbandlbl.Text = WingbandInput.Text
        rsT.Close()

AW
0
 
LVL 7

Author Comment

by:Navicerts
ID: 13977006
Thank you sir
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 13977604
Glad to be of assistance.

might I ask why you are using ADO and not ADO.NET?  ADO.NET is a much improved database interaction tool, and it would be a good idea for you to get familiar with it.

AW

0
 
LVL 7

Author Comment

by:Navicerts
ID: 13977945
I was just trying to throw something together for the boss real quick, but i will be making more permanant things working ahead that i would like to use whatever the "freshest" technology is (if anything just so it can be maintained longer).

Do you know a good place i can go to get an overview of the diffrences between the two?

Thanks for ths tip!

-Navicerts
0
 
LVL 7

Author Comment

by:Navicerts
ID: 13979048
Please see

Q_21420617.html

Thanks!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Screencast - Getting to Know the Pipeline
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question