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
firas shaar
NA
2
2.7k
problem in sum payments method
Aug 27 2013 6:22 AM
please someone help me
I have method that return payments values sum for workers imprests
public static double PaymentsvalueSum(int id)
{
string strconn = myproject.Properties.Settings.Default.SalariesConnectionString;
OleDbConnection conn = new OleDbConnection(strconn);
if (conn.State == ConnectionState.Closed)
{
conn.Open();
}
OleDbCommand command = new OleDbCommand("select SUM(Payment_Value) from imprests_payments WHERE Imprest_ID=@id;", conn);
command.Parameters.Add(new OleDbParameter("@id", id));
double sumvalue = (double)command.ExecuteScalar();
try
{ }
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
conn.Close();
}
return sumvalue;
}
when button_click event I write
private void button1_Click(object sender, EventArgs e)
{
double val = ImprestsPaysMgr.PaymentsvalueSum(int.Parse(GridViewImprestsPays.CurrentRow.Cells["Imprest_ID"].Value.ToString()));
textBox1.Text = val.ToString();
}
this code is working perfectly when payments values in imprests_payments table is available but my problem is when no payments values is available in imprests_payments table
where the following error is rising
Object reference not set to an instance of an object.
I need the solution for this problem
Reply
Answers (
1
)
ListView
email using exchange server in c#