I have one table which contains userid,name and role column. A user can have more than one role I nee to put all these values in one datagrid in vb.net
but i need to put the role separated by ,.
for ex
This data should come into a datagrid in vb.net
UserId Name Role
U1 ABC Admin,Super Admin,HR
Thanks
Arpita Tripathi
Loading
Jignesh TrivediPosted Jul 10, 2013, 11:24 PM
hi,
Agreee with above two answer.
Also recommend go with Store procedure and prepair required data in your sql result
Please refer like it might help you to find comma seperated value
http://www.c-sharpcorner.com/UploadFile/ff2f08/comma-separated-value-in-sql-query/
Mahesh ChandPosted Jul 10, 2013, 12:17 PM
Mahesh ChandPosted Jul 10, 2013, 12:16 PM
1. Your store procedure or SQL query should select data from both tables. For your application, it does not matter how many tables data is coming from. This is recommended.
2. Some developers do not have control over SQL queries or database. In that case, you bring data in two DataTables and then you merge or insert one record from Table 2 into Table 1.
Iftikar HussainPosted Jul 10, 2013, 12:14 PM
You can write the sql query like this
create a new SP as
in your code
Regards,
Iftikar