Dim sqlCon As SqlConnection = New SqlConnection("Password=my_password;Persist Security Info=True;User ID=plamen;Initial Catalog=Northwind;Data Source=OUR_SERVER") sqlCon.Open() Dim sqlCmd As SqlCommand = New SqlCommand() sqlCmd.CommandType = CommandType.StoredProcedure sqlCmd.CommandText = "sp_help" Dim param As SqlParameter = sqlCmd.Parameters.Add("@objname", SqlDbType.NVarChar, 776) param.Direction = ParameterDirection.Input param.Value = "Categories" sqlCmd.Connection = sqlCon Dim rs As SqlDataReader = sqlCmd.ExecuteReader() Dim s As Integer = 0 Do While rs.Read() s = s + 1 LoopI use "s" variable only to have statement inside the loop. Set breakpoint to the "Do While" row and start this code.
rs(0) rs(1) rs(2) rs(3)When code stops at the breakpoint, all statements shows "Run-time exception: InvalidOperationException...", so the first (and the only) row was not readed. When I step over "Do While" row, the statements into debugger shows correct values. When after "Loop" I go to the "Do While" row for the second time, Read() method returns False and I leave the loop.
Plamen Ivanov
MCSD .NET Early Achiever and MCAD .NET Charter Member (VB .NET/SQL Server 2000)
MCSD (VB 6.0/SQL Server 2000) br>
VB (.NET) - what other language do you need in the whole Universe?...