Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
BCullenward
Starting Member
28 Posts |
Posted - 2006-04-04 : 18:31:00
|
| I'm finding it difficult to find any posts/articles on reporting in SQL Server 2005. I have a report that requires the name of the person using the machine. I have a table that contains their name with the user name, and I can pull the username out by setting a variable to Environ("username"), however, I either need to create a sub-report or find a way to query the database with the username via the code.What would be the best way to do this, and if I have to do a sub-report, how do I pass parameters to the query?Your help is much appreciated.Thanks. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2006-04-04 : 18:35:24
|
| I'm not fully understanding your problem. Could you post the query that the report will use as well as the query to get the username from the table?Tara Kizeraka tduggan |
 |
|
|
BCullenward
Starting Member
28 Posts |
Posted - 2006-04-04 : 18:44:08
|
quote: Originally posted by tkizer I'm not fully understanding your problem. Could you post the query that the report will use as well as the query to get the username from the table?Tara Kizeraka tduggan
The query that drives the data for my report has nothing to do with who is logged on. It is simply order information that has an orderID and an Order Date. The report needs to put the person's name and username on the report. I can get the username, but am having difficulty with the method to use that to query the table that has the data I need.Is there a way via the code to do this?If not, do I need to do a cross join with the data pertaining to the order and the currently logged in user? |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2006-04-04 : 18:56:10
|
| You can use multiple data sets in a report. Go to the Data tab, use the dropdown and select New DataSet.Tara Kizeraka tduggan |
 |
|
|
BCullenward
Starting Member
28 Posts |
Posted - 2006-04-04 : 19:09:37
|
quote: Originally posted by tkizer You can use multiple data sets in a report. Go to the Data tab, use the dropdown and select New DataSet.Tara Kizeraka tduggan
Thanks, Is there a way to use the returned value from the report code to put in the second data set where I'm querying for the UserName? |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2006-04-04 : 19:13:49
|
| Could you provide an example of what you mean?Tara Kizeraka tduggan |
 |
|
|
BCullenward
Starting Member
28 Posts |
Posted - 2006-04-05 : 08:11:02
|
| textbox1.value = CODE.GetUserIDSQL for Dataset2 = "SELECT * FROM Employees WHERE USERNAME = '" & =CODE.GETuserID & "'"I'm trying to do something like that |
 |
|
|
|
|
|