Click here to Skip to main content
15,886,560 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hello sir.........i am doing one jsp project and i am having one table with columns first name
middle name
last name
mobile number
address
i want to concat first,middle,last name and i have to show a datagrid view as Name Mobile Number Address

for example-if table contais data as-
first name-raju
middle name-kumar
last name-dinkar
mobile no-89343849
address-bangalore

then i have to show data grid as-
Name-raju kumar dinkar
mobile no-89343849
address-bangalore

how can i do...i am trying using concat string tokenizer but its not happening.........plz haelp me..its urgent..????????
Posted

1 solution

Why not append/concatenate the column values in query itself when fetching the data?

For example:
SQL
SELECT
  (Firstname +" "+ middlename +" "+ lastname) as Name,
  mobilenumber
FROM
   myTable
 
Share this answer
 
v2
Comments
kumar ankit1 19-Jun-12 14:15pm    
sir i am using one query as-
String query ="SELECT(first_name +" "+ middle_name +" "+ last_name) as Name,city,state FROM user";
but here its showing one error as ';' expected.....my query is correct but why its showing error....??????
Sandeep Mewara 22-Jun-12 1:06am    
Difficult to comment.

Query reference link: http://msdn.microsoft.com/en-us/library/ms177561.aspx

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900