Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
14
Answers
ADO.NET DATAGRIDVIEW UPDATE
Bineesh VP
11y
827
1
Reply
Sir, I am doing a Program of ADO.NET
SAVE, UPDATE
and
DELETE
My form's name is frmProduct.
I want your help in the update process.
here is my form;
I did the coding for functioning Save and View.
the data passes from gridView to textBox when I double click in gridView and text of button Save change to "Update".
and I need your help from here.
I am getting error"
here is the code I wrote in the SP class;
public void productEdit(productInfo infoProduct)
{
try
{
if (sqlCon.State == ConnectionState.Closed)
{
sqlCon.Open();
}
SqlCommand sqlCmd = new SqlCommand("productEdit", sqlCon);
sqlCmd.CommandType = CommandType.StoredProcedure;
sqlCmd.Parameters.Add("@productId", SqlDbType.Decimal).Value = infoProduct.productId;
sqlCmd.Parameters.Add("@productName", SqlDbType.NVarChar).Value = infoProduct.productName;
sqlCmd.Parameters.Add("@purchaseRate", SqlDbType.Decimal).Value = infoProduct.purchaseRate;
sqlCmd.Parameters.Add("@salesRate", SqlDbType.Decimal).Value = infoProduct.salesRate;
int incount = sqlCmd.ExecuteNonQuery();
if (incount > 0)
{
MessageBox.Show("Update Successfully");
}
}
catch (Exception ex)
{
MessageBox.Show("PrSP04" + ex.Message);
}
finally
{
sqlCon.Close();
}
}
here the code I wrote in the button_click event
private void btnSave_Click(object sender, EventArgs e)
{
productInfo infoproduct=new productInfo();
productSP SpProduct=new productSP();
infoproduct.productId = decProduct;
infoproduct.productName = txtProductName.Text.ToString();
infoproduct.purchaseRate = decimal.Parse(txtpurchaseRate.Text);
infoproduct.salesRate = decimal.Parse(txtsalesReport.Text);
if (btnSave.Text == "Save")
{
SpProduct.productAdd(infoproduct);
}
else
{
SpProduct.productEdit(infoproduct);
}
ProductgridFill();
clearAll();
}
please help m
e i
n this error
Post
Reset
Cancel
Answers (
14
)
Next Recommended Forum
Object Oriented in Database applications
How to create an ODBC System DSN entry through C# for SQlite