TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ajit N
NA
352
71.3k
How to update data in DataGridView based on condition in sql
Jul 8 2018 5:17 AM
Hello, i want to update record ( based on condtion in sql query ) from DataGridView. i used the update method and i tried some code but it shows me below error on update method
OleDbCommand.Prepare method requires all parameters to have an explicitly set type.
OleDbDataAdapter da;
DataSet ds =
null
;
BindingSource bsource =
new
BindingSource();
ublic
void
BindData()
{
OleDbCommand cmd =
new
OleDbCommand(
"select srno,AccNumber,Admission_Fee,Family_fund,MonthlyCollection,MonthlyDeposit,Fund,SimpleLoanBal,SimpleInstallment,SimpleInt,UrgentLoanBal,UrgentInstallment,UrgentInt,EducationLoanBal,EducationInstallment,EducationInt,GuarantorInstallment,GuarantorInt,OtherLoanBal,OtherInstallment,OtherInt,BankLoanBal,BankInstallment,BankInt,TotalInstallment,OtherLoanCaption from transDemand where IssueDate=@IssueDate order by AccNumber Desc"
, con);
cmd.Parameters.AddWithValue(
"@IssueDate"
, datesearch.Value.ToString(
"dd-MM-yyyy"
));
da =
new
OleDbDataAdapter(cmd);
ds =
new
DataSet();
OleDbCommandBuilder cmdbuild =
new
OleDbCommandBuilder(da);
da.Fill(ds,
"transDemand"
);
bsource.DataSource = ds.Tables[
"transDemand"
];
dataGridView1.DataSource = bsource;
private
void
btnupdate_Click(
object
sender, EventArgs e)
{
DataTable dt = ds.Tables[
"transDemand"
];
this
.dataGridView1.BindingContext[dt].EndCurrentEdit();
this
.da.Update(dt);
BindData();
}
Reply
Answers (
5
)
Loginform to SQL database
c# window login form application