|
-
November 5th, 2003, 11:36 AM
#1
Moving select query result to variable
How can I get the value of a select query into a variable? For example, the result of this query "Select ID from table A" should be moved into variable X.
Also what is the syntax to write a sub-query. I tried the following and it does not seem to work.
"Select NAME from Table A where ID=( "Select AID from table B where SName like 'ABC' ")"
-
November 5th, 2003, 11:48 AM
#2
We need more details from you on this one.
Is this in an ADO.NET environment?
OLE/SQL?
Can you post the context of this code?
Good Luck,
Craig - CRG IT Solutions - Microsoft Gold Partner
-My posts after 08/2015 = .NET 4.x and Visual Studio 2015
-My posts after 11/2011 = .NET 4.x and Visual Studio 2012
-My posts after 02/2010 = .NET 4.0 and Visual Studio 2010
-My posts after 12/2007 = .NET 3.5 and Visual Studio 2008
-My posts after 04/2007 = .NET 3.0 and Visual Studio 2005
-My posts before 04/2007 = .NET 1.1/2.0
*I do not follow all threads, so if you have a secondary question, message me.
-
November 5th, 2003, 02:31 PM
#3
I use the OleDB connection to connect to the Access database which has 3 tables. The following is the code I have. I am trying to populate combo boxes with data from the tables. One of the combo box data needs to be displayed based on the previous combo box selection which is in a different table.
In line 4 below, I am trying to get the result of the select command into variable temp and in line 5 (which is not complete) I want to use the value of temp to get the fid. I want to either do this way or be able to use a subquery.
Private Sub cmbForms_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbForms.SelectedIndexChanged
1) DsAddendum1.Clear()
2) Dim temp As String
3) Dim paramval As String
4) temp = "Select fid from FG where fg.forms '" &cmbForms.SelectedItem.Row.ItemArray(0) & "'"
5) paramval = "Select addendum from addendum where fid=( " & temp )
6) daAddendum.SelectCommand.CommandText = temp
7) daAddendum.Fill(DsAddendum1)
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|