|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now! |
|
#1
|
|||
|
|||
|
SQL 2K Stored Procedure: VB.NET
This is my first shot at using Stored Procedures and VB. I have always used direct quaries against the DB. I AM HAVING TROUBLE AND NEED HELP. When I return a value from my stored procedure, if there's more than one row returned, how do I handle it? Here is my stored procedure:
CREATE PROCEDURE [dbo].[paw_GetOpenDates] (@WEEK int, @TEAMID nvarchar OUTPUT) AS SELECT HomeID FROM Schedule WHERE (VisitorID = 'NO') AND (Week = @WEEK) RETURN GO Here is my VB Code: Dim cn As SqlConnection = New SqlConnection("server=10.1.11.2;initial catalog=POWPOW;User ID=PAN;Password=PANDA;") Dim sqlcmd As SqlCommand = New SqlCommand("paw_GetOpenDates", cn) sqlcmd.CommandType = CommandType.StoredProcedure Dim sp As SqlParameter ' Dim SBError As New StringBuilder sp = sqlcmd.Parameters.Add("@WEEK", SqlDbType.Int) sp.Value = 1 ' Count Output Parameter sp = sqlcmd.Parameters.Add("@TEAMID", SqlDbType.NVarChar) sp.Size = 50 sp.Direction = ParameterDirection.Output Try cn.Open() sqlcmd.ExecuteNonQuery() --> dim jj =sqlcmd.Parameters("@TEAMID").Value <-- Catch objException As SqlException Dim objError As SqlError For Each objError In objException.Errors MsgBox(objError.Message) Next Catch ex As Exception MsgBox(ex.Message) Finally cn.Close() cn.Dispose() cn = Nothing End Try |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > SQL 2K Stored Procedure: VB.NET |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|