Let me try to explain:
With #1, you are supplying all the information that is needed to
execute the sql. Each bit of information is using a db connection.
Theoretically, #1 is faster.
With #2, while only using 3 connections, the process of discovery
(parameters, SQL text, etc) is using those connecttions, but asking
a lot of questions. #2 is theoretically slower.
Quoting Eliezer Broder <[EMAIL PROTECTED]>:
> I am having a most strange issue. I have two versions of the same code:
> CODE - version #1 cmd.CommandType = CommandType.StoredProcedure
>
> If iPlanetLogin_OR_UserDotIdentityDotName.StartsWith("AMG\") Then
> cmd.CommandText = "dbo.Persons_get_DomainAccount"
> cmd.Parameters.Add("@DomainAccount",
> iPlanetLogin_OR_UserDotIdentityDotName)
> Else
> cmd.CommandText = "dbo.persons_get_iPlanetAccount"
> cmd.Parameters.Add("@iPlanetAccount",
> iPlanetLogin_OR_UserDotIdentityDotName)
> End If
> and:
> CODE - version #2 If
> iPlanetLogin_OR_UserDotIdentityDotName.StartsWith("AMG\") Then
> cmd.CommandText = "dbo.Persons_get_DomainAccount '" &
> iPlanetLogin_OR_UserDotIdentityDotName & "'"
> Else
> cmd.CommandText = "dbo.persons_get_iPlanetAccount '" &
> iPlanetLogin_OR_UserDotIdentityDotName & "'"
> End If
>
> The first one creates 6 connections in the database, as is evidenced by:
> SELECT count(*) as PurchIS_Connections
> FROM Master.dbo.SysProcesses
> WHERE DBID IN (SELECT DBID
> FROM Master.dbo.SysDatabases
> WHERE [Name] LIKE '%PurchIs%' )
> and loginame ='PurchIS'
>
> and the second section of code only creates *3* connections.
>
> First of all, why are multiple connections being created here at all?
> Secondly, why should using parameters (i.e. setting cmd.CommandType =
> CommandType.StoredProcedure) double the number of connections at all? Isn't
>
> that the proper way to do call a SP in
> ADO<http://www.tek-tips.com/viewthread.cfm?qid=1103710&page=1#>
> .NET?!
>
> I have so many connections to the DB! Please help...
>
> Thanks,
> Eliezer
>
>
> [Non-text portions of this message have been removed]
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
------------------------ Yahoo! Groups Sponsor --------------------~-->
<font face=arial size=-1><a
href="http://us.ard.yahoo.com/SIG=12hk1ab3d/M=362329.6886308.7839368.1510227/D=groups/S=1705006764:TM/Y=YAHOO/EXP=1123280253/A=2894321/R=0/SIG=11dvsfulr/*http://youthnoise.com/page.php?page_id=1992
">Fair play? Video games influencing politics. Click and talk back!</a>.</font>
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/