Assigning Data to a variable in a query

I have a table that I want to query based on a Selected Record in a gridView.  I have the Record Number in GridView.SelectedValue but  I have no ide how to set up a query in here much less run it.  I need to know OldLine and oldItem from a table called items

I mean I know "Select OldItem, OldLine from ITems where RecordNumber = " + GridValue.SelectedValue"

 

Sure hoped that worked but no...  As you can probably tell I am relatively new to VB, VWD but not queries. 

 

Please can someone give me an example of how to do this in a Public Sub

The whole purpose is to get the old item number so I can display an image in a particular query.  I can do all but run the silly query and gather the data

Thanks in advance

 

 

 



Answer this question

Assigning Data to a variable in a query

  • papapet_2000

    Hi Mike,

    > I am relatively new to VB, VWD but not queries. 

    > how to do this in a Public Sub

    This forum is for questions about the Microsoft Visual FoxPro database and development tool. While many of us have experience with VB, you might get better help in a Visual Basic.NET newsgroup.

    > "Select OldItem, OldLine from ITems where RecordNumber = " + GridValue.SelectedValue"

    If that's your exact code then you've got an odd number of double quotes.

    Also, you haven't said exactly what the "doesn't work" behavior is, such as the exact text of any error messages.



  • Kevin Herbert

    How do you know GridView.SelectedValue holds record number in your backend It shows you what the current row's primary key value is.

    Is there a field in your backend called "RecordNumber" and what is its type

    For example with VFP's testdata.dbc customer table or SQL server's Northwind.Customers:

    strSelect = String.Format( "select Company,contact from Customer where cust_id = '{0}'", MyGridView.SelectedValue)

     


  • Dave__Dave

    No problem being on VFP forum. VFP community knows how to play with data and most of them also work with .Net:)


  • rjv_rnjn

    Oh I am sorry.  I did not know it was foxpro...  and yes the field in my table is called RecordNumber.

    What you told has helped me get started.  Thanks again


  • Assigning Data to a variable in a query