PDA

View Full Version : Could not find stored procedure



Fleewood
07 Dec 2011, 05:28 PM
Hi, I'm just going through an ASP.NET manual trying to learn VB, there are a couple of parts in the book that tell me to use stored procedures and I cant get them to work. I am definitely connected to my database, everything else works perfect except for stored procedures.

VB Code


Protected Sub UpdateItem(ByVal employeeId As Integer, ByVal newName As String, ByVal newUsername As String)
Dim conn As SqlConnection
Dim comm As SqlCommand
Dim connectionString As String = _
ConfigurationManager.ConnectionStrings( _
"Dorknozzle").ConnectionString
conn = New SqlConnection(connectionString)
comm = New SqlCommand("UpdateEmployee", conn)
comm.CommandType = System.Data.CommandType.StoredProcedure
comm.Parameters.Add("@EmployeeID", Data.SqlDbType.Int)
comm.Parameters("@EmployeeID").Value = employeeId
comm.Parameters.Add("@NewName", Data.SqlDbType.NVarChar, 50)
comm.Parameters("@NewName").Value = newName
comm.Parameters.Add("@NewUsername", Data.SqlDbType.NVarChar, 50)
comm.Parameters("@NewUsername").Value = newUsername
Try
conn.Open()
comm.ExecuteNonQuery()
Finally
conn.Close()
End Try
End Sub
End Class


Database .sql code



CREATE PROCEDURE UpdateEmployee
(
@EmployeeID Int,
@NewName nvarchar(50),
@NewUsername nvarchar(50)
)
AS
UPDATE Employees
SET Name = @NewName, Username = @NewUsername
WHERE EmployeeID = @EmployeeID