Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

populate a label from sql

Status
Not open for further replies.

oxenss

Programmer
Jun 20, 2003
8
US
I am very much a rooky programmer in my first internship and dont have a lot of help here. what I am trying to do is get a date field from the database to fill a label with the date. the date would be the hire date of an employee from a employee table. I have been fighting this for a couple of hours now and cant seem to figure it out. any help would be greatly apreciated.

Thank you in advance
 
a couple of questions to clarify your problem...
(1) What version is your database? (ex. SQL Server 2000)
(2) Are you trying to use a stored procedure?
(3) Is your problem getting the right data out of SQL or knowing what to do with it once you have it?
 
ok we are using microsoft access 2000 for the database
Im pretty sure im getting the data i want from my sql statement. I just can not figure out how to get the information from the sql statement and place it into a label. im not sure if im trying to use a stored procedure or not. they have built a class to handle the database connections. The project i am working on is going to be for an employee terminal so they can view their hours and other personal info. hoppefuly this clears the questions up!

 
Could you post some the code that is accessing the sql so we can take a look at it?

Have you tried this?
[assume vDate is the date field in question]
myLabel.Text = vDate.ToShortDateString

upworth
 
here is the sql statement and the code i have been trying to use that is not working hehe im going to try the code you suggested
thank you for your help upwoth
sql = "SELECT tblEmploymentEvents.Employee_Id, tblEmploymentEvents.dteEventDate, tblEmploymentEvents.strEvent " & _
"FROM tblEmploymentEvents " & _
"WHERE (Employee_ID = " & empid & ")"


Dim getdate As New query(sql, "tblEmploymentEvents")
getdate.getData()

' Dim dtset As DataSet = New DataSet()
'getdate.dbPath.insert( "tblEmploymentEvents"))
Dim dt As DataTable = getdate.reader("tblEmploymentEvents")
lblHrDte.Text = dt.Rows(0).Item("dteEventDate")

getdate.closedb()
getdate = Nothing
 
the information i am trying to get is this spacific field
tblEmploymentEvents.dteEventDate

 
If you know the name of the recordset being returned and which field it is in the stored procedure or the name in the stored procedure. Then you can easily use

Label1.text = MyRecordSet.Tables(0).rows(0).items(and put in the index of the field called or the name called, though if you put in the name use quotes around it).toshortdatestring

-Matt
 
thank you Herb this has gotten me much closer i think. what exactly is the record set? is that my sql statement or? I have actualy got text to go into the label but it is still not getting the date from the database I am so confused. thank you again for all your help
 
The record set is what was returned from the stored procedure or sql statement basically your dataset is a recordset.

Also I noticed you declared a dtDataSet as New DataSet, but you never populated the dataset. I think that might be your problem.

-Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top