How to retrieve data from database to frontend, each field in diff txtbox #1 1 Minute Ago | Add to Haimanti's Reputation | Flag Bad Post
hi
Hi i'm new to coding, with basis of theritical knowledge, i tried writing code for data insert n retrieval..
the code i posted last time may be confusing, but its because i'm not comfortable with syntaxes still.
pls guidde with with the same.
Program requirement is:
The data in data grid should display "edit" and "delete" options when mouse is right clicked on it. The user when selects edit on any data, the whole related record should be displayed on new form where user may edit one or more field of the record n update the same in Db.
On selection of "delete' the user should have a msg box flashing if he is sure to delete the record. If "ok" the record may be deleted, if "cancel" the datagrid should be again dispalyed.
Pls guide me as to how do i proceed. I'm stuck on thi ssingle part since long
The code i've trid is as below:
private void editToolStripMenuItem_Click(object sender, EventArgs e)
{
//frmInsertCustData frmInsertCustData = new frmInsertCustData();
//frmInsertCustData.Show();
//DataSet ds = new DataSet();
//SqlDataAdapter da = new SqlDataAdapter("Select * from customer order by id", conn1);
//da.Fill(ds, "customer");
//row = e.RowIndex;
//col = e.ColumnIndex;
}
private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
{
//SqlDataReader dr1 = new SqlDataReader();
//row = e.RowIndex;
//col = e.ColumnIndex;
//SqlDataAdapter da1 = new SqlDataAdapter("Delete from customer where @parameter =@value");
// if (MessageBoxDefaultButton.Button1 = true)
// da1.ExecuteNonQuery();
// else if (MessageBoxDefaultButton.Button2 = true)
// dataGridView2.Show();
MessageBox.Show("Do you want to delete the record","Delete",MessageBoxButtons.OKCancel);
DialogResult dialrslt = new DialogResult();
frmInsertCustData myfrm = new frmInsertCustData();
dialrslt = myfrm.ShowDialog();
if (dialrslt == DialogResult.OK)
{
MessageBox.Show("Deleted Record!!");
}
else if (dialrslt == DialogResult.Cancel)
MessageBox.Show("Action Reverted");
}
Thank you