Command object to manipulate data

Insert data

 private void addnewimage(string path, OleDbConnection cn, OleDbCommand cmd){

        //save image

        cmd = new  OleDbCommand("Insert Into tblimages(Path) Values('" + path + "')", cn)

        cmd.ExecuteNonQuery();

 

    }

 

Delete data

private void deleteimage(int id,  OleDbConnection cn,  OleDbCommand cmd){

        //delete image

        cmd = new OleDb.OleDbCommand("Delete * From tblimages Where ID=" + id, cn);

        cmd.ExecuteNonQuery();

        //update listview

        Lstimages.Items.Remove(Lstimages.SelectedItems[0]);

    }

 

Update data

private void updateimage(OleDbConnection cn,  OleDbCommand cmd){

        //update image

        cmd = new OleDbCommand("Update tblimages Set Path='" + txtpath.Text +"' Where ID=" + Form1.Lstimages.SelectedItems[0].Text,cn);

        cmd.ExecuteNonQuery();

    }




HTML Comment Box is loading comments...



This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.