Click here to Skip to main content
14,453,371 members
Rate this:
Please Sign up or sign in to vote.
See more:
i am new to development and want to know about the insertion deletion and updating of record from a FORM to database ,
Posted
Updated 19-Nov-19 22:22pm
Comments
   
A Form is irrelevant to database; it least it should be.
--SA
Rate this:
Please Sign up or sign in to vote.

Solution 4

   
Rate this:
Please Sign up or sign in to vote.

Solution 3

It might be helpful,

Simple ADO.NET Database Read, Insert, Update and Delete using C#.[^]

and further reading,

ADO.NET[^]

:)
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

You can get idea about insertion and Upadtion
For insertion
public static bool Insert_File(string FileNo, string CUSTOMER_NAME, string ProjectName, string STATUS,string date,string ins)
    {
        try
        {
            string stinsert = "Insert into File (FileNo,CUSTOMER_NAME,ProjectName,STATUS,IDate,InsertedBy) values (@FileNo,@CUSTOMER_NAME,@ProjectName,@STATUS,@date,@ins)";
            //string stinsert1 = "Insert into FileCord (FileNo,CUSTOMER_NAME,ProjectName,STATUS,IDate) values (@FileNo,@CUSTOMER_NAME,@ProjectName,@STATUS,@date)";
            
            OleDbCommand cmdinsert = new OleDbCommand(stinsert, GetConnection());
           
            cmdinsert.Parameters.AddWithValue("FileNo", FileNo);
            cmdinsert.Parameters.AddWithValue("CUSTOMER_NAME", CUSTOMER_NAME);
            cmdinsert.Parameters.AddWithValue("ProjectName", ProjectName);
            cmdinsert.Parameters.AddWithValue("STATUS", STATUS);
            cmdinsert.Parameters.AddWithValue("date",date);
            cmdinsert.Parameters.AddWithValue("ins",ins);
            cmdinsert.ExecuteNonQuery();
            cmdinsert.Connection.Close();
            return true;
           
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.ToString());
            return false;
        }
    }

For Update
public static bool Update_Received(string FileNo, string ReqControlNo, string ReceiveDate, string Remarks, string received)
    {
        try
        {
            string s1 = "Update Issue set ReceivedDate='" + ReceiveDate + "',ReceivedRemarks= '" + Remarks + "',ReceiveTime='" + received + "' where FileNo='" + FileNo + "' AND ReqControlNo='" + ReqControlNo + "'";
            OleDbCommand cmd1 = new OleDbCommand(s1, GetConnection());
            cmd1.ExecuteNonQuery();
            cmd1.Connection.Close();
            string stts = "Available";
            string st3 = "Update File set STATUS='" + stts + "' where FileNo='" + FileNo + "' ";
            OleDbCommand cmd11 = new OleDbCommand(st3, GetConnection());
            cmd11.ExecuteNonQuery();
            cmd11.Connection.Close();

            return true;

        }
        catch (Exception ex)
        {

            System.Windows.Forms.MessageBox.Show(ex.ToString());
            return false;
        }
   
Comments
arslan3488 13-Aug-11 5:27am
   
but when we use sql 2008 then what will be the way do this all stuff
uspatel 17-Aug-11 5:18am
   
you can use Sql in place of OleDb for sql server

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100