I'm facing this error that telling me I'm using an illegal variable or number and it highligh this line in my code Line 34:rowsAffected = command.ExecuteNonQuery();
. I think I have the issue in the parameters that need to be changed based on Oracle format but not sure. I did replace all the @
with p.Course_id
, then ?p.course
, p_course_id
as I did in my stored procedure in oracle but none of them work. I'm still getting same error.
Please help me sort out this issue. Thank you
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Configuration;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.OracleClient;
public class PostForum
{
public static int INSERTforum(int course_Id, string question, string posterName, DateTime blog_date)
{
int rowsAffected = 0;
using (OracleConnection connection = ConnectionManager.GetDatabaseConnection())
{
OracleCommand command = new OracleCommand("INSERTforum", connection);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("@course_Id", SqlDbType.Int).Value = course_Id;
command.Parameters.Add("@question", SqlDbType.VarChar).Value = question;
command.Parameters.Add("@posterName", SqlDbType.VarChar).Value = posterName;
command.Parameters.Add("@blogdate", SqlDbType.DateTime).Value = blog_date;
rowsAffected = command.ExecuteNonQuery();
}
return rowsAffected;
}
}
Here is my stored procedure
CREATE OR REPLACE PROCEDURE INSERTforum(
p_course_id IN forum.COURSE_ID%TYPE,
p_question IN forum.QUESTION%TYPE,
p_postername IN forum.POSTERNAME%TYPE,
p_blogdate IN forum.BLOG_DATE%TYPE)
AS
BEGIN
INSERT INTO forum ("COURSE_ID", "QUESTION", "POSTERNAME", "BLOG_DATE")
VALUES (p_course_id, p_question,p_postername, p_blogdate);
COMMIT;
END;
/