.net sukbir

Dear All,

Below is how I have form my query and populate my combo box.

SqlCeDataAdapter sqlDataAdapter2 = new SqlCeDataAdapter();

SqlCeCommand cmd2 = conn1.CreateCommand();

cmd2.CommandText = "Select concat(itemID,'#',itemName) as itemNameID, itemCode From tblItem ";

DataTable myDataTable2 = new DataTable();

sqlDataAdapter2.SelectCommand = cmd2;

sqlDataAdapter2.Fill(myDataTable2);

DataRow myfirst2 = myDataTable2.NewRow();

myfirst2["itemCode "] = "-Item Code-";

myDataTable2.Rows.InsertAt(myfirst2, 0);

cbKodJalan.DataSource = myDataTable2;

cbKodJalan.DisplayMember = "itemCode";

cbKodJalan.ValueMember = "itemNameID";

So basically the display will be just itemCode. But end of the day when I have selected the combo box item I also want to display in another function both the item name and item code separately. I will do based on a split function based on '#' but the problem is that the concat function is not supported in windows mobile database Any one can see my problem please Thanks.



Re: Smart Devices VB and C# Projects Concat function not working for mobile database

Alex Yakhnin MSFT

You should be able to use '+' instead of 'concat'. Something like that:

"SELECT itemID + '#' + itemName as itemName, itemCode FROM tblItem"






Re: Smart Devices VB and C# Projects Concat function not working for mobile database

.net sukbir

Dear Alex,

I tried you method unfortunately when I check the combination of itemID + '#' + itemName as itemName gives me all values of 0 Can you see what is the problem please Thanks.





Re: Smart Devices VB and C# Projects Concat function not working for mobile database

Alex Yakhnin MSFT

Make sure that all fields that you are trying to concatenate are of a type char (nvarchar, nchar etc...). If not, you will need to make a conversion using one of the conversion functions.






Re: Smart Devices VB and C# Projects Concat function not working for mobile database

.net sukbir

Dear Alex,

My itemID is now infact of type int. So where do you want me to convert in the database or during the query If during the query how will I convert is it using the Convert.ToString function Thanks.





Re: Smart Devices VB and C# Projects Concat function not working for mobile database

Alex Yakhnin MSFT

You can use CONVERT function in the SQL:

http://msdn2.microsoft.com/en-us/library/ms174450.aspx