sql statement for c# mysql

I try to put sql state ment  in c# but it not work this sql statement I test with phpMyAdmin it work how can i solve the problem

SELECT membernameH, SUM(
CASE WHEN htype = 'pin'
THEN amount
ELSE 0
END ) AS pin, SUM(
CASE WHEN htype = 'pfi'
THEN amount
ELSE 0
END ) AS pfi, SUM(
CASE WHEN htype = 'ppr'
THEN amount
ELSE 0
END ) AS ppr
FROM hpay
GROUP BY membernameH

sql.JPG
teeraAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

teeraAuthor Commented:
Pleser see error in picture
sql2.JPG
0
Ashish PatelCommented:
>>>>How can i solve the problem?

Paste the c# code here so that we can look at what you are doing to this statement.
0
teeraAuthor Commented:
I am new foe c# I just use datagride
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
 
namespace WindowsApplication2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
 
        private void CopyClick(object sender, EventArgs e)
        {
            textBox2.Text = textBox1.Text;
        }
 
        private void villageDataSetBindingSource_CurrentChanged(object sender, EventArgs e)
        {
 
        }
 
        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'villageDataSet.balanceborow' table. You can move, or remove it, as needed.
            this.balanceborowTableAdapter.Fill(this.villageDataSet.balanceborow);
 
        }
 
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
 
        }
    }
}

Open in new window

0
Ashish PatelCommented:
Try writting the query in one line in the DataGrid, as you query looks good.

SELECT membernameH, SUM(CASE WHEN htype = 'pin' THEN amount ELSE 0 END) AS pin, SUM(CASE WHEN htype = 'pfi' THEN amount ELSE 0 END ) AS pfi, SUM(CASE WHEN htype = 'ppr' THEN amount ELSE 0  END ) AS ppr FROM hpay GROUP BY membernameH
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gnoonCommented:
Try to use END CASE instead of END, for MySQL. http://dev.mysql.com/doc/refman/5.0/en/case-statement.html.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.