DisplayMember with two fields

  • Thread starter Thread starter Amirallia
  • Start date Start date
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
 
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
 
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!!!
 
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
 
Back
Top