Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...It's fun to see others going through the same stuff I did and be able to help. It's also a way for me to stay sharp and not lose the stuff I've learned..."

Geography

Where in the world do Tek-Tips members come from?

Importance of the parenthesis "()" <--- ???

NoobProgrammer (MIS)
28 Apr 09 16:11
The following are 2 lines that opens a sql connection via the sql .net namespace.  The first line does not work, but the second line does.  The only difference is the () after the Open function.

When I use the VS 2005 IDE, I believe this is optional, but apparently in PowerShell, this is not.  I've done some simple programming, but I don't understand the significance of the parenthesis.  Can somebody let me know or link me some info?  Thanks!

DOES NOT WORK!
$SqlConnection = New-Object System.Data.SqlClient.SqlConnection "server=myserver;database=database1;Integrated Security=sspi"
$SqlConnection.Open

WORKS!
$sqlConnection = new-object System.Data.SqlClient.SqlConnection "server=myserver;database=database1;Integrated Security=sspi"
$sqlConnection.Open()
markdmac (MIS)
29 Apr 09 9:56
I can't swear to it but I think the significance is that you are calling a function and the empty parenthesis indicate you are calling it without any arguments.

I hope you find this post helpful.  

Regards,

Mark

Check out my scripting solutions at http://www.thespidersparlor.com/vbscript

Work SMARTER not HARDER.  The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier!  Save time, get more work done, get the Admin Script Pack.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close