I have a database that I'm trying to inset data into called dogs.mdb.
For some reason the code below doesn't seem to insert a new record into the database...please help!
namespace dogs
{
public partial class Form1 : Form
{
public Form1()
{
string connection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=L:\\Billy Uni\\Application Program Development\\dogs1\\dogs1\\bin\\Debug\\dogs.mdb";
string command = "INSERT INTO dogs(Dog Name, Breed) VALUES('NewName', 'NewBreed')";
OleDbConnection myConn = new OleDbConnection(connection);
OleDbCommand myCmd = new OleDbCommand(command, myConn);
try
{
myConn.Open();
myCmd.ExecuteNonQuery();
}
catch (Exception e)
{
Console.WriteLine("Exception in DBHandler", ex);
}
finally
{
myConn.Close();
}
}
}
}
when I run the program there are no errors, it just doesnt do anything.
I'm very much a beginner at this so if I've missed something simple please dont be too harsh :)
Thanks in advance.