Welcome to Dream.In.Code
Getting VB.NET Help is Easy!

Join 136,547 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,844 people online right now. Registration is fast and FREE... Join Now!




Retrieving Column Contents from SQL Query

 
Reply to this topicStart new topic

Retrieving Column Contents from SQL Query, Retrieving Column Contents from SQL Query

DeCompile
23 Aug, 2008 - 05:11 PM
Post #1

D.I.C Head
**

Joined: 20 Jul, 2008
Posts: 180



Thanked: 6 times
My Contributions
I have a SQL Query that states:

select * from jobs where jobno = @jobno

......

Each Job Number is unique, and I can search through the jobs to make sure one exists from a textbox and button.

I have added a few labels to this form and am having troubles with label.text = a column contents from this above query.

Any help would be muchly appreciated.
User is offlineProfile CardPM
+Quote Post

Jayman
RE: Retrieving Column Contents From SQL Query
23 Aug, 2008 - 06:38 PM
Post #2

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 6,947



Thanked: 42 times
Dream Kudos: 500
Expert In: C#, VB.NET, Java

My Contributions
How are you retrieving the returned results from your SQL query? (ie. Command object, DataSet, etc)

Post the code that you are referring to and we will be able to provide you with an accurate answer.
User is offlineProfile CardPM
+Quote Post

DeCompile
RE: Retrieving Column Contents From SQL Query
23 Aug, 2008 - 07:29 PM
Post #3

D.I.C Head
**

Joined: 20 Jul, 2008
Posts: 180



Thanked: 6 times
My Contributions
I honestly can't remember (this is not my main working computer)

Although, when I use a static SQL query:

select * from jobs where jobno = '200'

I can actually go through and retrieve the value in the column.
User is offlineProfile CardPM
+Quote Post

Jayman
RE: Retrieving Column Contents From SQL Query
23 Aug, 2008 - 09:28 PM
Post #4

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 6,947



Thanked: 42 times
Dream Kudos: 500
Expert In: C#, VB.NET, Java

My Contributions
That may be so, but you indicated the problem is not with the query but when you try to assign the results to a Label.

So the problem lies with how you are assigning it to the Label control.
User is offlineProfile CardPM
+Quote Post

DeCompile
RE: Retrieving Column Contents From SQL Query
24 Aug, 2008 - 02:17 PM
Post #5

D.I.C Head
**

Joined: 20 Jul, 2008
Posts: 180



Thanked: 6 times
My Contributions
If Me.STOCKTableAdapter.FillBy_stockID(Me.DataSet1.PSTOCK, TextBox1.Text) <= 0 Then
MsgBox("Stock ID does not exist. Please RE-Enter.", , "Error...")
Else
Label10.Text = TextBox1.Text


That's using the FillBy_StockID query which is:

select * from stock where stock_id = @stockID

This returns a single record as all stockID's are unique. What I want to be able to do is retrieve the information in certain columns of the table eg. Job No. etc.

I've tried many different ways, but can't seem to get it.

The problem has not been assigning the value to the label.
*********************************
User is offlineProfile CardPM
+Quote Post

DeCompile
RE: Retrieving Column Contents From SQL Query
24 Aug, 2008 - 03:21 PM
Post #6

D.I.C Head
**

Joined: 20 Jul, 2008
Posts: 180



Thanked: 6 times
My Contributions
Not a worry.

Problem solvered.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 10:59PM

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month