Ciao a tutti sto utilizzando per la prima volta le store procedure
e sto cercando di farmi restituire quando creo un record con
ID contatore
Nome Varchar(20)
ll'ide che l'sql server da al nuovo record
sto facendo varie prove ma mi da alcuni errori che nn trovo
posto qui il codice
se qualcuno riesce ad individuare il problema ne sarei grato

%
Public Class outparamswithacommand


Public Sub Run()
Dim MsgString As String

Dim myConnection As SqlConnection

myConnection = New SqlConnection("server=(local);Trusted_Connection=y es; database= TestLinee")

Try
Dim CreateProcCommand As SqlCommand
Dim DropProcCommand As SqlCommand
CreateProcCommand = New SqlCommand("CREATE PROCEDURE InsertPercorso @Domenico nchar(15), @Identity int OUT as INSERT INTO PercorsoStradale (Denominazione) VALUES(@Domenico)RETURN @@ROWCOUNT", myConnection)
DropProcCommand = New SqlCommand("IF EXISTS (SELECT name FROM sysobjects WHERE name = 'InsertPercorso' AND type = 'P') DROP PROCEDURE InsertPercorso", myConnection)

myConnection.Open()
DropProcCommand.ExecuteNonQuery()
CreateProcCommand.ExecuteNonQuery()

Dim myCommand As SqlCommand
myCommand = New SqlCommand("InsertPercorso", myConnection)
myCommand.CommandType = CommandType.StoredProcedure
' Fill the parameters collection based upon stored procedure
Dim workParam As SqlParameter

workParam = myCommand.Parameters.Add("@@ROWCOUNT", SqlDbType.Int, 4)
' ParameterDirection.Input is the default for the Direction property. Thus the following line is not
' needed here. To set the Direction property to its default value, use the following line.
'workParam.Direction = ParameterDirection.Input

workParam = myCommand.Parameters.Add("@CompanyName", SqlDbType.NChar, 40)
workParam.Direction = ParameterDirection.Output



MsgString = myCommand.Parameters("@ROWCOUNT").Value.ToString()
Catch e As Exception
MsgString = e.ToString()
Finally
myConnection.Close()
End Try

MsgBox(MsgString)
End Sub
%