Re: Command obj OR Connection obj



If you use the Connection.Execute method, you'll have to provide a SQL
statement and will have to be careful about syntax (for example, with
quotes, commas, etc.).

If you use a Command object, you can set each parameter by name using
Command.Parameters. This is safer if the values are beyond your control. It
prevents people from injecting data that looks like SQL and executing
something you hadn't intended.

Other than that, as far as I know, it's just whatever is more convenient for
you.

Paul

"vbXML" <vbXML@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:7E04840C-FE1E-4B7A-BAF5-7A9466832AF1@xxxxxxxxxxxxxxxx
>I need to write a com+ class to wrap a Stored Procedure call that update a
> field in a table. I need to pass two parameters to the Stored Proc. What
> is
> best in this case a command object (add params and execute the sp) or use
> a
> 'execute' mtd on the connection object?
> I was wondering if opening a connection explicitly (when using execute mtd
> on connection obj) hinder/lock other users longer? whereas while using the
> command obj I only pass the connection-string to the activeconnection
> property of the command obj(my assumption, connection gets pooled in this
> case)?
> thanks!


.



Relevant Pages

  • SQL Server 2000 (Application) Role accessed through ADO.NET
    ... users from connecting to SQL Server through other MSOffice ... The database role claims to answer my ... I establish the connection to the database ... I execute sp_setapprole stored procedure (providing the ...
    (microsoft.public.sqlserver.security)
  • Re: IDENTITY_INSERT error
    ... > Session means same opened connection. ... > your command opens another connection and you could check it using SQL ... > Server) is to execute both statement in one batch separating them by ...
    (microsoft.public.data.ado)
  • Re: ADODB.Recordset: Operation is not allowed when the object is closed
    ... > ' Create the ADO Connection and Recordset objects. ... > ' Set the connection string, open the connection and execute the ... If your sql string is an insert/update/delete statement, ...
    (microsoft.public.scripting.vbscript)
  • Re: VBA - Testing Links to tables
    ... You can execute a stored procedure by creating a pass-through query in ... VBA code by creating a DAO QueryDef object and setting its connection ... Microsoft Access Developer's Guide to SQL Server ...
    (microsoft.public.sqlserver.programming)
  • Re: VBA - test link to tables
    ... Only way to test connection is to execute some sort of *light* SQL statement ...
    (microsoft.public.vb.database.ado)