Connecting Tech Pros Worldwide Help | Site Map

System.Data.DataViewManagerListItemTypeDescriptor Combobox

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 17th, 2005, 08:22 AM
Mike L
Guest
 
Posts: n/a
Default System.Data.DataViewManagerListItemTypeDescriptor Combobox

This is for a Win form.

The code below causes combo box to have
"System.Data.DataViewManagerListItemTypeDescriptor " in the drop down box.
What I'm I missing in my code to get the data out of the SP into the combo
box?

string sProc = "prGet_LicenseCode";
using (SqlConnection oCn = new
SqlConnection(sConnString))
{
using (SqlCommand oCmd = new
SqlCommand(sProc, oCn))
{
oCn.Open();
oCmd.CommandType =
CommandType.StoredProcedure;

oCmd.Parameters.Add("@sLicenseYear",
SqlDbType.NChar, 6);

oCmd.Parameters["@sLicenseYear"].Value = txtLicYear.Text;

SqlDataAdapter oDa = new
SqlDataAdapter();

oDa.SelectCommand = oCmd;
DataSet ds=new DataSet();
oDa.Fill(ds);

int numTables = ds.Tables.Count;
//No table no records.
if (numTables < 1)
{
MessageBox.Show("No License
Codes found for that year.", "No record found", MessageBoxButtons.OK);

}
else
{
cboPrivilege.DataSource = ds;
}
}
}


  #2  
Old November 17th, 2005, 08:22 AM
Ollie Riches
Guest
 
Posts: n/a
Default Re: System.Data.DataViewManagerListItemTypeDescriptor Combobox

Your bindings for the ComboBox are not complete, you want something like
this I believe:

//DataViewManager provided through the DataSet.DefaultViewManager
property
this.comboBox1.DataSource=ds.DefaultViewManager;

//display "someTable.SomeID" value in the ComboBox
this.comboBox1.DisplayMember="someTable.SomeID";


Where 'someTable' and 'someTable.SomeID' are replaced with the value you
require.

HTH

Ollie Riches


"Mike L" <Cadel@nospam.nospam> wrote in message
news:4E8F8508-2332-4D76-AEF2-B5C19ABBC8ED@microsoft.com...[color=blue]
> This is for a Win form.
>
> The code below causes combo box to have
> "System.Data.DataViewManagerListItemTypeDescriptor " in the drop down box.
> What I'm I missing in my code to get the data out of the SP into the combo
> box?
>
> string sProc = "prGet_LicenseCode";
> using (SqlConnection oCn = new
> SqlConnection(sConnString))
> {
> using (SqlCommand oCmd = new
> SqlCommand(sProc, oCn))
> {
> oCn.Open();
> oCmd.CommandType =
> CommandType.StoredProcedure;
>
>
> oCmd.Parameters.Add("@sLicenseYear",
> SqlDbType.NChar, 6);
>
> oCmd.Parameters["@sLicenseYear"].Value = txtLicYear.Text;
>
> SqlDataAdapter oDa = new
> SqlDataAdapter();
>
> oDa.SelectCommand = oCmd;
> DataSet ds=new DataSet();
> oDa.Fill(ds);
>
> int numTables = ds.Tables.Count;
> //No table no records.
> if (numTables < 1)
> {
> MessageBox.Show("No License
> Codes found for that year.", "No record found", MessageBoxButtons.OK);
>
> }
> else
> {
> cboPrivilege.DataSource =
> ds;
> }
> }
> }
>[/color]


  #3  
Old November 17th, 2005, 08:23 AM
Mike L
Guest
 
Posts: n/a
Default Re: System.Data.DataViewManagerListItemTypeDescriptor Combobox

No, still comes up with error in combo box.
this.cboPrivilege.DataSource = ds.DefaultViewManager;
this.cboPrivilege.DisplayMember = "SALES_REVENUE.LICENSE_CODE";







"Ollie Riches" wrote:
[color=blue]
> Your bindings for the ComboBox are not complete, you want something like
> this I believe:
>
> //DataViewManager provided through the DataSet.DefaultViewManager
> property
> this.comboBox1.DataSource=ds.DefaultViewManager;
>
> //display "someTable.SomeID" value in the ComboBox
> this.comboBox1.DisplayMember="someTable.SomeID";
>
>
> Where 'someTable' and 'someTable.SomeID' are replaced with the value you
> require.
>
> HTH
>
> Ollie Riches
>
>
> "Mike L" <Cadel@nospam.nospam> wrote in message
> news:4E8F8508-2332-4D76-AEF2-B5C19ABBC8ED@microsoft.com...[color=green]
> > This is for a Win form.
> >
> > The code below causes combo box to have
> > "System.Data.DataViewManagerListItemTypeDescriptor " in the drop down box.
> > What I'm I missing in my code to get the data out of the SP into the combo
> > box?
> >
> > string sProc = "prGet_LicenseCode";
> > using (SqlConnection oCn = new
> > SqlConnection(sConnString))
> > {
> > using (SqlCommand oCmd = new
> > SqlCommand(sProc, oCn))
> > {
> > oCn.Open();
> > oCmd.CommandType =
> > CommandType.StoredProcedure;
> >
> >
> > oCmd.Parameters.Add("@sLicenseYear",
> > SqlDbType.NChar, 6);
> >
> > oCmd.Parameters["@sLicenseYear"].Value = txtLicYear.Text;
> >
> > SqlDataAdapter oDa = new
> > SqlDataAdapter();
> >
> > oDa.SelectCommand = oCmd;
> > DataSet ds=new DataSet();
> > oDa.Fill(ds);
> >
> > int numTables = ds.Tables.Count;
> > //No table no records.
> > if (numTables < 1)
> > {
> > MessageBox.Show("No License
> > Codes found for that year.", "No record found", MessageBoxButtons.OK);
> >
> > }
> > else
> > {
> > cboPrivilege.DataSource =
> > ds;
> > }
> > }
> > }
> >[/color]
>
>
>[/color]
  #4  
Old November 17th, 2005, 08:24 AM
Kevin Yu [MSFT]
Guest
 
Posts: n/a
Default Re: System.Data.DataViewManagerListItemTypeDescriptor Combobox

Hi Cadel,

Please try to change cboPrivilege.DataSource = ds; to

this.cboPrivilege.DataSource = ds.Tables[0];
this.cboPrivilege.DisplayMember = "SALES_REVENUE.LICENSE_CODE"; //if
SALES_REVENUE.LICENSE_CODE is the column name.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

  #5  
Old November 17th, 2005, 08:45 AM
Mike L
Guest
 
Posts: n/a
Default Re: System.Data.DataViewManagerListItemTypeDescriptor Combobox

Kevin your right again. I had the table name AND the column name like Ollie
told me, but when I just have the column name it worked.

Thanks.

"Kevin Yu [MSFT]" wrote:
[color=blue]
> Hi Cadel,
>
> Please try to change cboPrivilege.DataSource = ds; to
>
> this.cboPrivilege.DataSource = ds.Tables[0];
> this.cboPrivilege.DisplayMember = "SALES_REVENUE.LICENSE_CODE"; //if
> SALES_REVENUE.LICENSE_CODE is the column name.
>
> Kevin Yu
> =======
> "This posting is provided "AS IS" with no warranties, and confers no
> rights."
>
>[/color]
  #6  
Old November 17th, 2005, 08:45 AM
Kevin Yu [MSFT]
Guest
 
Posts: n/a
Default Re: System.Data.DataViewManagerListItemTypeDescriptor Combobox

You're welcome.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.