It's returning 10.
and for some reason it's counting those inserts as well. Note that running
"CT" wrote:
> Hi Chris,
>
> It works fine here, well I created a sample Random table in the Northwind
> database on the local SQL Server 2000 db server, with a single column of
> datatype nvarchar and copied from the Customers table (had to change the
> SELECT statement to select from the CustomerID column), but the return value
> is 5.
>
> I hate to ask, but it is 10 and not -1 you get back, right?
>
> --
> Carsten Thomsen
> Enterprise Development with VS .NET, UML, AND MSF
>
http://www.apress.com/book/bookDisplay.html?bID=105 >
> "Chris" <Chris@discussions.microsoft.com> wrote in message
> news:04C05A5A-280D-4A4D-B063-731C5706BC40@microsoft.com...
> > According to the docs, for the following code, I should get 5 rows
> > returned.
> > However, when I run this, n = 10. Is that a bug, or something I don't
> > understand?
> >
> >
> > Dim conn As SqlConnection
> > Dim cmd As SqlCommand
> > Dim dr As SqlDataReader
> > conn = New SqlConnection(Lookups.connStr)
> > conn.Open()
> > cmd = conn.CreateCommand
> > cmd.Connection = conn
> >
> > Dim x As Integer = 5
> >
> > cmd.CommandText = "insert into Random (id) " & _
> > "select top " & x & " id" & _
> > " from OtherTable order by newid()"
> > Dim n As Integer
> >
> > ' this should be 5, but returns 10
> > n = cmd.ExecuteNonQuery()
> >
> > conn.Close()
> > conn = Nothing
> >
> >
> >
>
>