G
Graham Blandford
Hi all,
Well I abandoned the use of a datagrid in my windows form and have opted to
use a listbox instead.
I have, following a helpful article created an item class and loaded it with
values from an ADO recordset.
Now, if I read the data I get a field (clientid) looking like this;
{FE84ACD5-8263-11D7-B0E7-0080AE000001}
when in fact, the actual data (as viewed using say a binding to a datagrid)
looks like this;
fe84acd5-8263-11d7-b0e7-0080ae000001
Why is it placing {} around the string and CASING up?
AAARRRRGGGHHHH!!
Here's some code snippets - where could this be happening?
By the way - I'm forced to use ADO as the dataaccess method in this case -
it is pulled from a 3rd-party reference which returns an ADO recordset.
I guess I could load the data into a dataset prior to reading - but then I'm
not sure how I read through the set sequentially.....
The defined class:-
Private clientid As String
Private Class ClientListItem
Private clientid As String
Private clientname As String
Public Sub New(ByVal id As String, ByVal name As String)
clientid = id
clientname = name
End Sub
Public Property listclientid() As String
Get
Return clientid
End Get
Set(ByVal Value As String)
clientid = Value
End Set
End Property
Public Property listclientname() As String
Get
Return clientname
End Get
Set(ByVal Value As String)
clientname = Value
End Set
End Property
Public Overrides Function ToString() As String
' this can be whatever you want to show in the listbox
Return clientname & " " & clientid
End Function
End Class
And here's the loading of the data into the listbox;
If rsclients.State <> ADODB.ObjectStateEnum.adStateClosed Then
rsclients.MoveFirst()
While Not rsclients.EOF
id = Trim(rsclients.Fields(0).Value)
name = rsclients.Fields("clientname").Value
' Debug.WriteLine(rsclients.Fields("clientid").Value & " " &
rsclients.Fields("clientname").Value)
' Debug.WriteLine(id.ToString & " " & name.ToString)
Dim liclients As New ClientListItem(id.ToString, name.ToString)
lstClients.Items.Add(liclients)
rsclients.MoveNext()
End While
End If
If anyone has any ideas I'd appreciate it.
Thanks,
Graham
Well I abandoned the use of a datagrid in my windows form and have opted to
use a listbox instead.
I have, following a helpful article created an item class and loaded it with
values from an ADO recordset.
Now, if I read the data I get a field (clientid) looking like this;
{FE84ACD5-8263-11D7-B0E7-0080AE000001}
when in fact, the actual data (as viewed using say a binding to a datagrid)
looks like this;
fe84acd5-8263-11d7-b0e7-0080ae000001
Why is it placing {} around the string and CASING up?
AAARRRRGGGHHHH!!
Here's some code snippets - where could this be happening?
By the way - I'm forced to use ADO as the dataaccess method in this case -
it is pulled from a 3rd-party reference which returns an ADO recordset.
I guess I could load the data into a dataset prior to reading - but then I'm
not sure how I read through the set sequentially.....
The defined class:-
Private clientid As String
Private Class ClientListItem
Private clientid As String
Private clientname As String
Public Sub New(ByVal id As String, ByVal name As String)
clientid = id
clientname = name
End Sub
Public Property listclientid() As String
Get
Return clientid
End Get
Set(ByVal Value As String)
clientid = Value
End Set
End Property
Public Property listclientname() As String
Get
Return clientname
End Get
Set(ByVal Value As String)
clientname = Value
End Set
End Property
Public Overrides Function ToString() As String
' this can be whatever you want to show in the listbox
Return clientname & " " & clientid
End Function
End Class
And here's the loading of the data into the listbox;
If rsclients.State <> ADODB.ObjectStateEnum.adStateClosed Then
rsclients.MoveFirst()
While Not rsclients.EOF
id = Trim(rsclients.Fields(0).Value)
name = rsclients.Fields("clientname").Value
' Debug.WriteLine(rsclients.Fields("clientid").Value & " " &
rsclients.Fields("clientname").Value)
' Debug.WriteLine(id.ToString & " " & name.ToString)
Dim liclients As New ClientListItem(id.ToString, name.ToString)
lstClients.Items.Add(liclients)
rsclients.MoveNext()
End While
End If
If anyone has any ideas I'd appreciate it.
Thanks,
Graham