From: Dan Guzman on
The rows affected messages you see in SSMS are generated by the tool in
response to DONE_IN_PROC messages returned by SQL Server. I could be wrong
but I believe SMO ignores DONE_IN_PROC messages. If you need the rowcount,
consider using a different API. The SqlCommand.ExecuteNonQuery method in
ADO.NET returns an integer which you can use to generate those messages
(assuming SET NOCOUNT OFF). For example:

int rowCount = command.ExecuteNonQuery();
Console.WriteLine(string.Format("{0} rows affected by query", rowCount));

--
Hope this helps.

Dan Guzman
SQL Server MVP

"Tim_Mac" <mackey.tim(a)gmail.com> wrote in message
news:1165491377.313948.324230(a)79g2000cws.googlegroups.com...
> hi dan, thanks for the follow up.
> when i run the same query in a management studio query window, i get
> the message "x rows affected by query". similarly when i run a command
> to create a stored procedure, i get a message saying the command
> completed successfully. these are the ones i'm interested in.
> it's not too serious if it isn't possible, because i know that specific
> errors throw exceptions which i can handle. it's just for
> informational purposes with the app i'm developing.
>
> thanks
> tim
>

From: Tim_Mac on
thanks Dan, i was surprised myself to see that the SMO ExecuteNonQuery
method had no int return value like ADO. i can live with it!

thanks again
tim

From: Dan Guzman on
I was also a bit surprised since many other facets are more closely aligned
with ADO.NET. That said, SMO is mostly intended for admin apps and while
SqlClient is better for hard-core data access.

--
Hope this helps.

Dan Guzman
SQL Server MVP

"Tim_Mac" <mackey.tim(a)gmail.com> wrote in message
news:1165578409.475436.307400(a)n67g2000cwd.googlegroups.com...
> thanks Dan, i was surprised myself to see that the SMO ExecuteNonQuery
> method had no int return value like ADO. i can live with it!
>
> thanks again
> tim
>

First  |  Prev  | 
Pages: 1 2
Prev: GhostCleanUpTask - every 4 seconds!?
Next: TEMPDB full