I am doing a program in school that keeps track on enrollment for a fake school


So far i can add/update/view Students and Instructors

But when i try to add a new course using the same code it doesn't work.

the only difference i can see is that the Course table on the data base as a foreign key from the Instructor table

Would that affect the way i have to code the Add and update functions of my courses class?


this is what i have right now

VB Code:
  1. Public Function Update() As Boolean
  2.         Dim isSuccessful As Boolean
  3.         Dim conn As New SqlConnection(connstring)
  4.         Dim sql As String = "UpdateCourse"
  5.         comm = New SqlCommand(sql, conn)
  6.         comm.CommandType = CommandType.StoredProcedure
  7.         comm.Parameters.Add(New SqlParameter("@COURSECODE", Me.mCourseCode))
  8.         comm.Parameters.Add(New SqlParameter("@COURSENAME", Me.mCourseName))
  9.         comm.Parameters.Add(New SqlParameter("@INSTRUCTORID", Me.mInstructorId))
  10.        
  11.         Try
  12.             conn.Open()
  13.             comm.ExecuteNonQuery()
  14.             isSuccessful = True
  15.         Catch ex As Exception
  16.             isSuccessful = False
  17.         End Try
  18.         Return isSuccessful
  19.     End Function

my storedprocedure is

VB Code:
  1. ALTER PROCEDURE dbo.UpdateCourse
  2.  
  3. @COURSECODE varchar(30),
  4. @COURSENAME varchar(30),
  5. @INSTRUCTORID bigint
  6. AS
  7. UPDATE Course       SET CourseName=@COURSENAME, InstructorID=@INSTRUCTORID
  8.                     WHERE CourseCode=@COURSECODE

I am using sqlServer 2005 and visual studio 2005