Click here to Skip to main content
15,912,837 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
is there anyone who can transform below C# method for insert into a MS SQL database to insert into an Oracle database?

Thanks in advance!

public void AddItem(string title, string description, decimal price, int categoryID)
{
  SqlConnection con = new SqlConnection(connectionString);

  // Create the Command.
  string insertSQL = "INSERT INTO Items ";
  insertSQL += "(Title, Description, Price, Category_ID)";
  insertSQL += "VALUES (@Title, @Description, @Price, @CategoryID)";

  SqlCommand cmd = new SqlCommand(insertSQL, con);

  cmd.Parameters.AddWithValue("@Title", title);
  cmd.Parameters.AddWithValue("@Description", description);
  cmd.Parameters.AddWithValue("@Price", price);
  cmd.Parameters.AddWithValue("@CategoryID", categoryID);

  try
  {
    con.Open();
    cmd.ExecuteNonQuery();
  }
  finally
  {
    con.Close();
  }
}
Posted
Updated 17-Nov-10 18:32pm
v2
Comments
Sandeep Mewara 18-Nov-10 1:08am    
Well, did you put any effort?

1 solution

I cant see the problem - what error occurs if you run the code?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900