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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get the user name?

Status
Not open for further replies.

knzy

Programmer
Jan 25, 2002
63
0
0
CA
Hi! All,

I am working on a report which needs to show the user's name. The user is the person who is generating the report. I think I need to get the user name from windows. How can I do it ? Do I need to call any Windows API?

Regards,
Knzy
 
Dear Knzy,

Depending on the database you are reporting against, you can get it by using a sql expression for example in SQL server the expression is:

{fn USER()}

Oracle has similar functionality.

Ro Rosemary Lieberman
rosemary@microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.
 
Dear Ro,

Thanks for your quick response. The database I am reporting against doesn't support any sql expression. And I want to get the Windows user name not the dababase user name.

Regards,
Knzy
 
Do a Google Search, I saw a udf one time that gets the windows user and machine name.

Hope that helps,

ro Rosemary Lieberman
rosemary@microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.
 
KNZY,

I started to do the search for you and didn't even realize that Crystal Reports 1 Forum has a faq on writing your own dll to do this with the code:

faq767-1284

I hope that helps you out a little more. I know I saw one for download but I can't find it now.

ro Rosemary Lieberman
rosemary@microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.
 
Hi! Ro,

As you said in the second post, I searched in Google and found the same solution as in the FAQ. I've just installed VB6.0 to create a .dll.

I will keep you updated tomorrow.

Thank you for your information.

Knzy
 
Hi! All,

According to the FAQ mentioned above and articles in kbase, I created UDF successfully. Everything looks fine until I run the report. The formula contains the UDF show nothing on the report.

Any idea?

Regards,
Knzy
 
Rosemary,

I tried your code for he SQL expression, but the version of CR I am using errors out when I execute the report. The SQL expression field itslef had no error when I checked it. I am using CR v8.5 professional, on a MS SQL Server 2000 database.

Any ideas? Software Sales, Training and Support for Macola, Crystal Reports and Goldmine
dgilsdorf@mchsi.com
 
Dgillz,

The syntax is driver specific. What driver?

I was using the Microsoft SQL Server 2000.81.7713.00 SqlSrv32.dll

ro Rosemary Lieberman
rosemary@microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.
 
Hi! All,

After all, I created and called the UDF sucessfully. Thank you all for your help. The problem I encountered is caused by an error in the VB source code I copied from another website.

Thanks again, Ro.

Regards,
Knzy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top