Retrieving Column Contents from SQL Query

Retrieving Column Contents from SQL Query

Page 1 of 1

5 Replies - 2048 Views - Last Post: 24 August 2008 - 04:21 PM Rate Topic: -----

#1 DeCompile  Icon User is offline

  • D.I.C Regular

Reputation: 19
  • View blog
  • Posts: 301
  • Joined: 20-July 08

Retrieving Column Contents from SQL Query

Posted 23 August 2008 - 06:11 PM

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.
Is This A Good Question/Topic? 0
  • +

Replies To: Retrieving Column Contents from SQL Query

#2 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: Retrieving Column Contents from SQL Query

Posted 23 August 2008 - 07:38 PM

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.
Was This Post Helpful? 0
  • +
  • -

#3 DeCompile  Icon User is offline

  • D.I.C Regular

Reputation: 19
  • View blog
  • Posts: 301
  • Joined: 20-July 08

Re: Retrieving Column Contents from SQL Query

Posted 23 August 2008 - 08:29 PM

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.
Was This Post Helpful? 0
  • +
  • -

#4 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: Retrieving Column Contents from SQL Query

Posted 23 August 2008 - 10:28 PM

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.
Was This Post Helpful? 0
  • +
  • -

#5 DeCompile  Icon User is offline

  • D.I.C Regular

Reputation: 19
  • View blog
  • Posts: 301
  • Joined: 20-July 08

Re: Retrieving Column Contents from SQL Query

Posted 24 August 2008 - 03:17 PM

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.
*********************************
Was This Post Helpful? 0
  • +
  • -

#6 DeCompile  Icon User is offline

  • D.I.C Regular

Reputation: 19
  • View blog
  • Posts: 301
  • Joined: 20-July 08

Re: Retrieving Column Contents from SQL Query

Posted 24 August 2008 - 04:21 PM

Not a worry.

Problem solvered.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1