C# and Database: How to Insert New record and save it
Dear All,
I am a very much new to C#. Today I developed my first database application using c#.
I am doing this to bind records:
txtLastName.DataBindings.Add("text", myds, "pm.last_name");
To move to next record(clicking next button):
CurrencyManager cm = (CurrencyManager)this.BindingContext[myds, "pm"];
if (cm.Position < cm.Count - 1)
{
cm.Position++;
}
else
MessageBox.Show("End of records", "my application", MessageBoxButtons.OK, MessageBoxIcon.Information);
and so on.
I have completed the record navigation functionality(FirstRecord, LastRecord, Next, Previous).
Problem:
I don't know how can I insert a new record and save it.
Please guide me in the above mentioned application.
Also recommend a good tuturial+example on web.
Thanks
Re: C# and Database: How to Insert New record and save it
There are numerous tutorial links in my signature. Some are ADO.NET specific and others have ADO.NET sections but much more besides.
Re: C# and Database: How to Insert New record and save it
Ok. I am going to look into the links.
Thanks.
Re: C# and Database: How to Insert New record and save it
Note that many of the tutorials are VB-based but the principles are exactly the same and there are links to code converters in my sig also, so you can convert the code examples if required. They are not 100% reliable but they do a good job in most cases and certainly enough to give you enough of an idea that you can fix any remaining issues by hand.
Re: C# and Database: How to Insert New record and save it
What kind of database you're using? You could use a simple INSERT statement to insert into the table that you desire.
Re: C# and Database: How to Insert New record and save it
engineer:
As JenniferBabe pointed out, we don't know what DMS you are using.
Assuming you are using Access, you might find this example helpful.