wooi83

wooi83

  • NA
  • 18
  • 0

unable to insert data. Pls help.

Mar 31 2004 4:13 PM
i need to know why i can't insert both variables to my database? it keeps return false when i click save button. no compilation and runtime errors occur. is my database table restricted access or my sql query is has erros? please give suggestion for this. public bool StoreBooksReservation(string UID, string BID) { SqlParameter[] Param = { new SqlParameter("@reservationUserID", SqlDbType.VarChar), new SqlParameter("@reservationBookID", SqlDbType.VarChar) }; Param[0].Value = UID; Param[1].Value = BID; try { return DC.SProcedures("SP_InsertReserve", Param); } catch { return false; } } public bool SProcedures(String SProcName, SqlParameter[] Param) { SqlCommand myCmd = CreateCommand(SProcName, Param, CommandType.StoredProcedure); try { myCmd.ExecuteNonQuery(); return true; } catch { return false; } } //stored procedure in sql 2000 CREATE PROCEDURE SP_InsertReserve ( @reservationUserID varchar, @reservationBookID varchar ) AS INSERT INTO dbo.RESERVATIONS( dbo.RESERVATIONS.reservationUserID, dbo.RESERVATIONS.reservationBookID ) VALUES ( @reservationUserID,@reservationBookID ) GO

Answers (3)