Reputation: 163
I have a DatagridView control that has 4 columns.
I want the FirstName
, MiddleName
and LastName
to be merged and call it as FullName
.
Like this :
My codes as of now is :
public void Data()
{
_da = new SqlDataAdapter();
_da.SelectCommand = cmd;
DataTable _dt = new DataTable();
_da.Fill(_dt);
BindingSource bs = new BindingSource();
bs.DataSource = _dt;
PresDG.DataSource = bs;
_da.Update(_dt);
}
private void President()
{
sc.Open();
cmd = new SqlCommand("SELECT * FROM TableVote WHERE Position='President'", sc);
try
{
Data();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
sc.Close();
}
}
How do I do it in my Sql Statement? Thanks in advance :)
Upvotes: 0
Views: 437
Reputation: 3128
try using
cmd = new SqlCommand("SELECT FirstName+' '+MiddleName+' '+LastName as FullName,VCount FROM TableVote WHERE Position='President'", sc);
Upvotes: 3