Hi,
I am just trying to learn ASP.NET but have run into a problem when attempting to insert data into my database.
I am using Oracle 10g Express Edition, Visual Studio 2005 and the code is in C#.
Here is the code I am using to call the insert statement;
string sql = "INSERT INTO offices (office_number, city, address, tel_number) VALUES (45, 'London', 'Tottenham', '2342234234');";
OracleCommand command = new OracleCommand();
using (OracleConnection myConnection = new
OracleConnection(ConfigurationManager.ConnectionStrings[
"connectionString"].ConnectionString))
{
command.CommandText = sql;
command.Connection = myConnection;
try
{
myConnection.Open();
command.ExecuteNonQuery();
myConnection.Close();
}
catch (Exception ex)
{
...
}
}
The connection string is;
<add name="ConnectionString" connectionString="Data Source=XE;Persist Security Info=True;User ID=xxx;Password=xxx" providerName="System.Data.OracleClient"/>
</
connectionStrings>
I have created a function that retrieves data from the database OK which is displayed in a grid view, but when I run the insert nothing is inserted into the database. I don't get any errors and I'm confident that the connection to DB is OK as I have already been able to retrieve data as mentioned, I just dont know if there is something I am missing such as a commit for example? Have looked on the web and tried it a couple of different ways but still can't find a solution.
Any help would be gratefully received.
Regards