DisplayMember with two fields

A

Amirallia

Hi everybody...

I use VS 2005 with WinCE 5.0

Here is my code :

Sub ChargerClasse()
Dim dtTable03 As New DataTable
Dim daTable03 As New SqlServerCe.SqlCeDataAdapter
Dim Cmd As New SqlServerCe.SqlCeCommand

Try
Me.cbxClasse.Items.Clear()

Cmd.CommandText = "SELECT Num_class, (Num_class & ' - ' &
Des_abr) as Designation FROM Table03 ORDER BY Des_abr"
daTable03.SelectCommand = Cmd
daTable03.SelectCommand.Connection = ConnDB
daTable03.Fill(dtTable03)

Me.cbxClasse.DataSource = dtTable03
Me.cbxClasse.DisplayMember = "Designation"
Me.cbxClasse.ValueMember = "Num_class"

Catch g As SqlServerCe.SqlCeException
MessageBox.Show(g.NativeError & "::" & g.Message)
Catch ex As Exception
MessageBox.Show(ex.Message & " : " & "ChargerClasse")
End Try
End Sub

Sql mobile doesn't accept the "as" statment in the sql ?

I must use this to set the Me.cbxClasse.DisplayMember with two fields.

Any idea to get the "Me.cbxClasse.DisplayMember" with two fields ?

Thanks
 
G

Guest

AS works fine - I've used it before. It's possible that it doesn't like
your non-standard '&' concatenation. SQL uses a '+' for string
concatenation so you might see if that helps (you didn't say what the
failure mode is).


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com
 
A

Amirallia

I try

Cmd.CommandText = "SELECT Num_class, (Num_class + ' - ' + Des_abr) as
Designation FROM Table03 ORDER BY Des_abr"

But error message when execute daTable03.Fill(dtTable03).

If I try "SELECT Num_class, (Des_abr) as Designation FROM Table03 ORDER
BY Des_abr", it's ok!!!
 
G

Guest

What error? You're only giving us half the picture. And I'm not sure that
the parens are right either. Remove them.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top