Combo Box will not bind

  • Thread starter Thread starter Dave Londeck
  • Start date Start date
D

Dave Londeck

I am using ver 1.1 of the Framework and progamming in VB.NET.

I am going after a stored procedure which returns 3 rows. Zero rows appear
in the combo box.
I need to bind 2 columns. One for the value member and the other for the
display member.

I am positive that this proceduee returns rows because I see it while
stepping through the code.

Dim SQLDBObjects As New SQLObjects(DBConnection)
Dim dsProcedures As New DataSet

'Returns a dataset containing stored procedures for this database
dsProcedures = SQLDBObjects.ProcedureList

cboDBObject.Items.Clear()
cboDBObject.DataSource = dsProcedures.Tables("ProcedureList")
cboDBObject.DisplayMember = "ObjectName"
cboDBObject.ValueMember = "ObjectID"

Any Ideas....
 
with this code snippet, it's difficult to understand. but, try to see
rowcount of dsprocedures("Procedurelist") or try to work with datatable
instead of dataset.

Rajesh Patel
 
you are sure that your sp returns 3 rows. so, now check datatable's
rowcount, how many rows you are retrieving in dataset after dsProcedures =
SQLDBObjects.ProcedureList statement. or may be try to put your dim
statements on the top, not in any procedure. and check again.

I think you don't need statement cboDBObject.Items.Clear().


Rajesh Patel
 
I am changing the contents of this combo box to show either tables or
procedures.
Therefore I am clearing the items so that the combo box is clear as to what
it contains.

I am triggering this on the checked proprerty of two radio buttons.
I am confused. This is not supposed to be this hard.
My rowcount is 3 and I can even view the items in ther respective columns.
The data just not displaying in the combo box.
 
I am using either

SELECT DISTINCT dbo.sysobjects.[id] AS ObjectID,
dbo.sysobjects.[name] AS ObjectName
FROM dbo.sysobjects
WHERE ([name] NOT LIKE N'sys%')
AND ([name] NOT LIKE N'dt_%')
AND (xtype = 'p')
order by dbo.sysobjects.[name]

OR

SELECT DISTINCT dbo.syscolumns.id AS ObjectID, dbo.sysobjects.name AS
ObjectName

FROM dbo.syscolumns

INNER JOIN
dbo.systypes ON dbo.syscolumns.xtype = dbo.systypes.xtype

INNER JOIN dbo.sysobjects
ON dbo.syscolumns.id = dbo.sysobjects.id

WHERE (dbo.sysobjects.name NOT LIKE N'sys%')
AND (dbo.sysobjects.xtype = 'u')
AND (dbo.sysobjects.name NOT LIKE 'dt_%')
Order by dbo.sysobjects.name
 
I expect that you are not mapping to the correct resultset from the stored
procedure. A SP returns N resultsets--one for each operation that it
performs. Only SELECT statements return rowsets and these can be empty as
well. Let's see the SP.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
Yup, those are pretty simple SPs. Unless the SP has additional logic that's
generating an additional resultset, this should work. I would try to
simplify the SP to the bare bones and work up from there. We've done this
many times (bind to a rowset from a SP).

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

Dave Londeck said:
I am using either

SELECT DISTINCT dbo.sysobjects.[id] AS ObjectID,
dbo.sysobjects.[name] AS ObjectName
FROM dbo.sysobjects
WHERE ([name] NOT LIKE N'sys%')
AND ([name] NOT LIKE N'dt_%')
AND (xtype = 'p')
order by dbo.sysobjects.[name]

OR

SELECT DISTINCT dbo.syscolumns.id AS ObjectID, dbo.sysobjects.name AS
ObjectName

FROM dbo.syscolumns

INNER JOIN
dbo.systypes ON dbo.syscolumns.xtype = dbo.systypes.xtype

INNER JOIN dbo.sysobjects
ON dbo.syscolumns.id = dbo.sysobjects.id

WHERE (dbo.sysobjects.name NOT LIKE N'sys%')
AND (dbo.sysobjects.xtype = 'u')
AND (dbo.sysobjects.name NOT LIKE 'dt_%')
Order by dbo.sysobjects.name


William (Bill) Vaughn said:
I expect that you are not mapping to the correct resultset from the stored
procedure. A SP returns N resultsets--one for each operation that it
performs. Only SELECT statements return rowsets and these can be empty as
well. Let's see the SP.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
I deleted the control and added a new one with the same name.

It is working fine now.

Thank you for your help.

William (Bill) Vaughn said:
Yup, those are pretty simple SPs. Unless the SP has additional logic that's
generating an additional resultset, this should work. I would try to
simplify the SP to the bare bones and work up from there. We've done this
many times (bind to a rowset from a SP).

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

Dave Londeck said:
I am using either

SELECT DISTINCT dbo.sysobjects.[id] AS ObjectID,
dbo.sysobjects.[name] AS ObjectName
FROM dbo.sysobjects
WHERE ([name] NOT LIKE N'sys%')
AND ([name] NOT LIKE N'dt_%')
AND (xtype = 'p')
order by dbo.sysobjects.[name]

OR

SELECT DISTINCT dbo.syscolumns.id AS ObjectID, dbo.sysobjects.name AS
ObjectName

FROM dbo.syscolumns

INNER JOIN
dbo.systypes ON dbo.syscolumns.xtype = dbo.systypes.xtype

INNER JOIN dbo.sysobjects
ON dbo.syscolumns.id = dbo.sysobjects.id

WHERE (dbo.sysobjects.name NOT LIKE N'sys%')
AND (dbo.sysobjects.xtype = 'u')
AND (dbo.sysobjects.name NOT LIKE 'dt_%')
Order by dbo.sysobjects.name


William (Bill) Vaughn said:
I expect that you are not mapping to the correct resultset from the stored
procedure. A SP returns N resultsets--one for each operation that it
performs. Only SELECT statements return rowsets and these can be empty as
well. Let's see the SP.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

I am using ver 1.1 of the Framework and progamming in VB.NET.

I am going after a stored procedure which returns 3 rows. Zero rows
appear
in the combo box.
I need to bind 2 columns. One for the value member and the other
for
the
display member.

I am positive that this proceduee returns rows because I see it while
stepping through the code.

Dim SQLDBObjects As New SQLObjects(DBConnection)
Dim dsProcedures As New DataSet

'Returns a dataset containing stored procedures for this database
dsProcedures = SQLDBObjects.ProcedureList

cboDBObject.Items.Clear()
cboDBObject.DataSource = dsProcedures.Tables("ProcedureList")
cboDBObject.DisplayMember = "ObjectName"
cboDBObject.ValueMember = "ObjectID"

Any Ideas....
 
I couldn't tell from your post if this was an Asp.Net page or a WinForm. If
this is Asp.Net you have to call cboDBObjectItems.DataBind() after setting
the datasource. A winform doesn't require this call to DataBind.
 
Back
Top