PC Review


Reply
Thread Tools Rate Thread

cant populate comboboxes in XP

 
 
Mike Fellows
Guest
Posts: n/a
 
      25th Feb 2004
when i load my windows form i populate a combobox i use the code below

Dim conn As New System.Data.SqlClient.SqlConnection(strConn)
Dim sql As String = "AllLenders"
Dim da As New System.Data.SqlClient.SqlDataAdapter(sql, conn)
Dim ds As New DataSet()
da.Fill(ds)
ComboBox1.DataSource = ds.Tables(0)
ComboBox1.DisplayMember = "Lender"
da.Dispose()
ds.Dispose()


This code compiles and works perfectly on my win2k box
now when someone takes my compiled executable and runs it on
windows xp, the combobox is not populated!

Ive also tried compiling it on a windows xp box and it still does not
work

the sql string is a stored procedure

im desperate for help with this as ive hit a brick wall!

Thanks

Mike Fellows


 
Reply With Quote
 
 
 
 
EricJ
Guest
Posts: n/a
 
      25th Feb 2004
don't know if this is it but
you bind the combo to a dataset and then dispose the dataset
unles someone has a better sollution have a look in that direction

hope it helps

eric

"Mike Fellows" <(E-Mail Removed)> wrote in message
news:7o0%b.959$44.378@newsfe1-win...
> when i load my windows form i populate a combobox i use the code below
>
> Dim conn As New System.Data.SqlClient.SqlConnection(strConn)
> Dim sql As String = "AllLenders"
> Dim da As New System.Data.SqlClient.SqlDataAdapter(sql, conn)
> Dim ds As New DataSet()
> da.Fill(ds)
> ComboBox1.DataSource = ds.Tables(0)
> ComboBox1.DisplayMember = "Lender"
> da.Dispose()
> ds.Dispose()
>
>
> This code compiles and works perfectly on my win2k box
> now when someone takes my compiled executable and runs it on
> windows xp, the combobox is not populated!
>
> Ive also tried compiling it on a windows xp box and it still does not
> work
>
> the sql string is a stored procedure
>
> im desperate for help with this as ive hit a brick wall!
>
> Thanks
>
> Mike Fellows
>
>



 
Reply With Quote
 
Mike Fellows
Guest
Posts: n/a
 
      25th Feb 2004
Nah,

didnt make any difference not disposing of the dataset

so im still as stuck as i was before


"EricJ" <(E-Mail Removed)> wrote in message
news:403c9946$0$783$(E-Mail Removed)...
> don't know if this is it but
> you bind the combo to a dataset and then dispose the dataset
> unles someone has a better sollution have a look in that direction
>
> hope it helps
>
> eric
>
> "Mike Fellows" <(E-Mail Removed)> wrote in message
> news:7o0%b.959$44.378@newsfe1-win...
> > when i load my windows form i populate a combobox i use the code below
> >
> > Dim conn As New System.Data.SqlClient.SqlConnection(strConn)
> > Dim sql As String = "AllLenders"
> > Dim da As New System.Data.SqlClient.SqlDataAdapter(sql, conn)
> > Dim ds As New DataSet()
> > da.Fill(ds)
> > ComboBox1.DataSource = ds.Tables(0)
> > ComboBox1.DisplayMember = "Lender"
> > da.Dispose()
> > ds.Dispose()
> >
> >
> > This code compiles and works perfectly on my win2k box
> > now when someone takes my compiled executable and runs it on
> > windows xp, the combobox is not populated!
> >
> > Ive also tried compiling it on a windows xp box and it still does not
> > work
> >
> > the sql string is a stored procedure
> >
> > im desperate for help with this as ive hit a brick wall!
> >
> > Thanks
> >
> > Mike Fellows
> >
> >

>
>



 
Reply With Quote
 
Gerry O'Brien [MVP]
Guest
Posts: n/a
 
      25th Feb 2004
Just out of curiousity, you are using strConn as the connection string for
your connection object. You don't display it here, perhaps for security
reasons, but my question is this.

Are you using a data source name on the 2K box that is not present on the XP
box? If your strConn is an actual connection string pointing to a DB,
ensure that the location and DB are the same on both systems.

One way to debug this real quick is to do a table count or a row count on
the table to see if you are returning any rows at all. This will narrow the
search as to where the problem lies, either DB connectivity or combo box
problem.

I'm inclined to believe that for some reason, you are not really connecting
to the DB.

--
Gerry O'Brien
Visual Developer .NET MVP



"Mike Fellows" <(E-Mail Removed)> wrote in message
news:7o0%b.959$44.378@newsfe1-win...
> when i load my windows form i populate a combobox i use the code below
>
> Dim conn As New System.Data.SqlClient.SqlConnection(strConn)
> Dim sql As String = "AllLenders"
> Dim da As New System.Data.SqlClient.SqlDataAdapter(sql, conn)
> Dim ds As New DataSet()
> da.Fill(ds)
> ComboBox1.DataSource = ds.Tables(0)
> ComboBox1.DisplayMember = "Lender"
> da.Dispose()
> ds.Dispose()
>
>
> This code compiles and works perfectly on my win2k box
> now when someone takes my compiled executable and runs it on
> windows xp, the combobox is not populated!
>
> Ive also tried compiling it on a windows xp box and it still does not
> work
>
> the sql string is a stored procedure
>
> im desperate for help with this as ive hit a brick wall!
>
> Thanks
>
> Mike Fellows
>
>



 
Reply With Quote
 
Mike Fellows
Guest
Posts: n/a
 
      25th Feb 2004
my strconn looks like this

Dim strConn As String =
"server=Gringotts;uid=*****;pwd=*****;database=lender"

i did a row count on my dataset and both return me 10 rows

now im even more stuck as i now know the data is there just not filling the
combobox!

Mike


"Gerry O'Brien [MVP]" <(E-Mail Removed)> wrote in message
news:u1HfiV6%(E-Mail Removed)...
> Just out of curiousity, you are using strConn as the connection string for
> your connection object. You don't display it here, perhaps for security
> reasons, but my question is this.
>
> Are you using a data source name on the 2K box that is not present on the

XP
> box? If your strConn is an actual connection string pointing to a DB,
> ensure that the location and DB are the same on both systems.
>
> One way to debug this real quick is to do a table count or a row count on
> the table to see if you are returning any rows at all. This will narrow

the
> search as to where the problem lies, either DB connectivity or combo box
> problem.
>
> I'm inclined to believe that for some reason, you are not really

connecting
> to the DB.
>
> --
> Gerry O'Brien
> Visual Developer .NET MVP
>
>
>
> "Mike Fellows" <(E-Mail Removed)> wrote in message
> news:7o0%b.959$44.378@newsfe1-win...
> > when i load my windows form i populate a combobox i use the code below
> >
> > Dim conn As New System.Data.SqlClient.SqlConnection(strConn)
> > Dim sql As String = "AllLenders"
> > Dim da As New System.Data.SqlClient.SqlDataAdapter(sql, conn)
> > Dim ds As New DataSet()
> > da.Fill(ds)
> > ComboBox1.DataSource = ds.Tables(0)
> > ComboBox1.DisplayMember = "Lender"
> > da.Dispose()
> > ds.Dispose()
> >
> >
> > This code compiles and works perfectly on my win2k box
> > now when someone takes my compiled executable and runs it on
> > windows xp, the combobox is not populated!
> >
> > Ive also tried compiling it on a windows xp box and it still does not
> > work
> >
> > the sql string is a stored procedure
> >
> > im desperate for help with this as ive hit a brick wall!
> >
> > Thanks
> >
> > Mike Fellows
> >
> >

>
>



 
Reply With Quote
 
EricJ
Guest
Posts: n/a
 
      25th Feb 2004
humor me (i don't like bound combos they have given me to much nightmares
)
below is a small listitem class you could use (this has always worked for
me)

loop the dataset
'code
dim li as clslistitem
combobox1.items.clear()

for each dr as datarow in ds.tables(0).rows
li = new clslistitem()
li.text = dr(1) 'or dr("Lender")
li.Obj = dr
combobox1.items.add(li)
next
'end code

to use the cbo
dim li as clslistitem
li = combobox1.selecteditem
dim dr as datarow
dr = li.obj

'code
Public Class clsListItem

Private Tekst As String
Private objke As Object

Public Sub New()
Tekst = ""
objke = new Object
End Sub

Public Sub New(ByVal te As String)
Tekst = te
objke = new Object
End Sub



Public Property Text() As String
Get
Return Tekst
End Get
Set(ByVal Value As String)
Tekst = Value
End Set
End Property


Public Property Obj() As Object
Get
Return objke
End Get
Set(ByVal Value As Object)
objke = Value
End Set
End Property

Public Overrides Function ToString() As String
Return Tekst
End Function


End Class


"Mike Fellows" <(E-Mail Removed)> wrote in message
news:AR1%b.975$44.633@newsfe1-win...
> my strconn looks like this
>
> Dim strConn As String =
> "server=Gringotts;uid=*****;pwd=*****;database=lender"
>
> i did a row count on my dataset and both return me 10 rows
>
> now im even more stuck as i now know the data is there just not filling

the
> combobox!
>
> Mike
>
>
> "Gerry O'Brien [MVP]" <(E-Mail Removed)> wrote in message
> news:u1HfiV6%(E-Mail Removed)...
> > Just out of curiousity, you are using strConn as the connection string

for
> > your connection object. You don't display it here, perhaps for security
> > reasons, but my question is this.
> >
> > Are you using a data source name on the 2K box that is not present on

the
> XP
> > box? If your strConn is an actual connection string pointing to a DB,
> > ensure that the location and DB are the same on both systems.
> >
> > One way to debug this real quick is to do a table count or a row count

on
> > the table to see if you are returning any rows at all. This will narrow

> the
> > search as to where the problem lies, either DB connectivity or combo box
> > problem.
> >
> > I'm inclined to believe that for some reason, you are not really

> connecting
> > to the DB.
> >
> > --
> > Gerry O'Brien
> > Visual Developer .NET MVP
> >
> >
> >
> > "Mike Fellows" <(E-Mail Removed)> wrote in message
> > news:7o0%b.959$44.378@newsfe1-win...
> > > when i load my windows form i populate a combobox i use the code below
> > >
> > > Dim conn As New System.Data.SqlClient.SqlConnection(strConn)
> > > Dim sql As String = "AllLenders"
> > > Dim da As New System.Data.SqlClient.SqlDataAdapter(sql, conn)
> > > Dim ds As New DataSet()
> > > da.Fill(ds)
> > > ComboBox1.DataSource = ds.Tables(0)
> > > ComboBox1.DisplayMember = "Lender"
> > > da.Dispose()
> > > ds.Dispose()
> > >
> > >
> > > This code compiles and works perfectly on my win2k box
> > > now when someone takes my compiled executable and runs it on
> > > windows xp, the combobox is not populated!
> > >
> > > Ive also tried compiling it on a windows xp box and it still does not
> > > work
> > >
> > > the sql string is a stored procedure
> > >
> > > im desperate for help with this as ive hit a brick wall!
> > >
> > > Thanks
> > >
> > > Mike Fellows
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Cor
Guest
Posts: n/a
 
      25th Feb 2004
Hi Gerry,

I take your message to Help Mike, because the last sentence from your
message should throw a connection error if it is true, but because he can
probably not debug on the XP computer I find your idea of counting
intresting.

Hi Mike,

Can you add this after your strConn = etc and change the name of your
table?.

Dim myCommand As New SqlCommand("select count(*) from MyTable", strConn)
myCommand.Connection.Open()
Dim count As Integer = CInt(myCommand.ExecuteScalar())
messagebox.show(count.tostring)
Conn.Close()

I am also curious.

(By the way, can you tell why you dispose those resources of the dataset and
the dataadapter)

Cor


 
Reply With Quote
 
Mike Fellows
Guest
Posts: n/a
 
      25th Feb 2004
EricJ,

I cant get your code to work at all

i created the class with no problems

i then put the other code section into the onformload sub
but your for statement does not work and to be honest i cant read your code

but the main problem im still having is that my orignal code works fine in
win2k
but does not work in windows xp - i cant see why there should be a
difference
as fundementally the Os's are still the same.




"EricJ" <(E-Mail Removed)> wrote in message
news:403cb6a9$0$311$(E-Mail Removed)...
> humor me (i don't like bound combos they have given me to much

nightmares
> )
> below is a small listitem class you could use (this has always worked for
> me)
>
> loop the dataset
> 'code
> dim li as clslistitem
> combobox1.items.clear()
>
> for each dr as datarow in ds.tables(0).rows
> li = new clslistitem()
> li.text = dr(1) 'or dr("Lender")
> li.Obj = dr
> combobox1.items.add(li)
> next
> 'end code
>
> to use the cbo
> dim li as clslistitem
> li = combobox1.selecteditem
> dim dr as datarow
> dr = li.obj
>
> 'code
> Public Class clsListItem
>
> Private Tekst As String
> Private objke As Object
>
> Public Sub New()
> Tekst = ""
> objke = new Object
> End Sub
>
> Public Sub New(ByVal te As String)
> Tekst = te
> objke = new Object
> End Sub
>
>
>
> Public Property Text() As String
> Get
> Return Tekst
> End Get
> Set(ByVal Value As String)
> Tekst = Value
> End Set
> End Property
>
>
> Public Property Obj() As Object
> Get
> Return objke
> End Get
> Set(ByVal Value As Object)
> objke = Value
> End Set
> End Property
>
> Public Overrides Function ToString() As String
> Return Tekst
> End Function
>
>
> End Class
>
>
> "Mike Fellows" <(E-Mail Removed)> wrote in message
> news:AR1%b.975$44.633@newsfe1-win...
> > my strconn looks like this
> >
> > Dim strConn As String =
> > "server=Gringotts;uid=*****;pwd=*****;database=lender"
> >
> > i did a row count on my dataset and both return me 10 rows
> >
> > now im even more stuck as i now know the data is there just not filling

> the
> > combobox!
> >
> > Mike
> >
> >
> > "Gerry O'Brien [MVP]" <(E-Mail Removed)> wrote in message
> > news:u1HfiV6%(E-Mail Removed)...
> > > Just out of curiousity, you are using strConn as the connection string

> for
> > > your connection object. You don't display it here, perhaps for

security
> > > reasons, but my question is this.
> > >
> > > Are you using a data source name on the 2K box that is not present on

> the
> > XP
> > > box? If your strConn is an actual connection string pointing to a DB,
> > > ensure that the location and DB are the same on both systems.
> > >
> > > One way to debug this real quick is to do a table count or a row count

> on
> > > the table to see if you are returning any rows at all. This will

narrow
> > the
> > > search as to where the problem lies, either DB connectivity or combo

box
> > > problem.
> > >
> > > I'm inclined to believe that for some reason, you are not really

> > connecting
> > > to the DB.
> > >
> > > --
> > > Gerry O'Brien
> > > Visual Developer .NET MVP
> > >
> > >
> > >
> > > "Mike Fellows" <(E-Mail Removed)> wrote in message
> > > news:7o0%b.959$44.378@newsfe1-win...
> > > > when i load my windows form i populate a combobox i use the code

below
> > > >
> > > > Dim conn As New System.Data.SqlClient.SqlConnection(strConn)
> > > > Dim sql As String = "AllLenders"
> > > > Dim da As New System.Data.SqlClient.SqlDataAdapter(sql, conn)
> > > > Dim ds As New DataSet()
> > > > da.Fill(ds)
> > > > ComboBox1.DataSource = ds.Tables(0)
> > > > ComboBox1.DisplayMember = "Lender"
> > > > da.Dispose()
> > > > ds.Dispose()
> > > >
> > > >
> > > > This code compiles and works perfectly on my win2k box
> > > > now when someone takes my compiled executable and runs it on
> > > > windows xp, the combobox is not populated!
> > > >
> > > > Ive also tried compiling it on a windows xp box and it still does

not
> > > > work
> > > >
> > > > the sql string is a stored procedure
> > > >
> > > > im desperate for help with this as ive hit a brick wall!
> > > >
> > > > Thanks
> > > >
> > > > Mike Fellows
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Mike Fellows
Guest
Posts: n/a
 
      25th Feb 2004
EricJ

got it working (id missed a line - apologies)

it works fine in both XP and Win2k

Thanks for your help

Mike


"EricJ" <(E-Mail Removed)> wrote in message
news:403cb6a9$0$311$(E-Mail Removed)...
> humor me (i don't like bound combos they have given me to much

nightmares
> )
> below is a small listitem class you could use (this has always worked for
> me)
>
> loop the dataset
> 'code
> dim li as clslistitem
> combobox1.items.clear()
>
> for each dr as datarow in ds.tables(0).rows
> li = new clslistitem()
> li.text = dr(1) 'or dr("Lender")
> li.Obj = dr
> combobox1.items.add(li)
> next
> 'end code
>
> to use the cbo
> dim li as clslistitem
> li = combobox1.selecteditem
> dim dr as datarow
> dr = li.obj
>
> 'code
> Public Class clsListItem
>
> Private Tekst As String
> Private objke As Object
>
> Public Sub New()
> Tekst = ""
> objke = new Object
> End Sub
>
> Public Sub New(ByVal te As String)
> Tekst = te
> objke = new Object
> End Sub
>
>
>
> Public Property Text() As String
> Get
> Return Tekst
> End Get
> Set(ByVal Value As String)
> Tekst = Value
> End Set
> End Property
>
>
> Public Property Obj() As Object
> Get
> Return objke
> End Get
> Set(ByVal Value As Object)
> objke = Value
> End Set
> End Property
>
> Public Overrides Function ToString() As String
> Return Tekst
> End Function
>
>
> End Class
>
>
> "Mike Fellows" <(E-Mail Removed)> wrote in message
> news:AR1%b.975$44.633@newsfe1-win...
> > my strconn looks like this
> >
> > Dim strConn As String =
> > "server=Gringotts;uid=*****;pwd=*****;database=lender"
> >
> > i did a row count on my dataset and both return me 10 rows
> >
> > now im even more stuck as i now know the data is there just not filling

> the
> > combobox!
> >
> > Mike
> >
> >
> > "Gerry O'Brien [MVP]" <(E-Mail Removed)> wrote in message
> > news:u1HfiV6%(E-Mail Removed)...
> > > Just out of curiousity, you are using strConn as the connection string

> for
> > > your connection object. You don't display it here, perhaps for

security
> > > reasons, but my question is this.
> > >
> > > Are you using a data source name on the 2K box that is not present on

> the
> > XP
> > > box? If your strConn is an actual connection string pointing to a DB,
> > > ensure that the location and DB are the same on both systems.
> > >
> > > One way to debug this real quick is to do a table count or a row count

> on
> > > the table to see if you are returning any rows at all. This will

narrow
> > the
> > > search as to where the problem lies, either DB connectivity or combo

box
> > > problem.
> > >
> > > I'm inclined to believe that for some reason, you are not really

> > connecting
> > > to the DB.
> > >
> > > --
> > > Gerry O'Brien
> > > Visual Developer .NET MVP
> > >
> > >
> > >
> > > "Mike Fellows" <(E-Mail Removed)> wrote in message
> > > news:7o0%b.959$44.378@newsfe1-win...
> > > > when i load my windows form i populate a combobox i use the code

below
> > > >
> > > > Dim conn As New System.Data.SqlClient.SqlConnection(strConn)
> > > > Dim sql As String = "AllLenders"
> > > > Dim da As New System.Data.SqlClient.SqlDataAdapter(sql, conn)
> > > > Dim ds As New DataSet()
> > > > da.Fill(ds)
> > > > ComboBox1.DataSource = ds.Tables(0)
> > > > ComboBox1.DisplayMember = "Lender"
> > > > da.Dispose()
> > > > ds.Dispose()
> > > >
> > > >
> > > > This code compiles and works perfectly on my win2k box
> > > > now when someone takes my compiled executable and runs it on
> > > > windows xp, the combobox is not populated!
> > > >
> > > > Ive also tried compiling it on a windows xp box and it still does

not
> > > > work
> > > >
> > > > the sql string is a stored procedure
> > > >
> > > > im desperate for help with this as ive hit a brick wall!
> > > >
> > > > Thanks
> > > >
> > > > Mike Fellows
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Cor
Guest
Posts: n/a
 
      25th Feb 2004
Hi Mike,

But the suske and wiske class from Eric should not be necessary, this is
real strange.
Did you for the datarow use that dararow (1) or that "Lender"?

Cor


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Populate comboboxes based on query taxidermist@cableone.net Microsoft Access Form Coding 2 7th Nov 2007 03:18 PM
One Table - Two ComboBoxes - Populate and edit linked fields of each larpup Microsoft Access Form Coding 0 6th May 2006 02:23 AM
Comboboxes to populate from table =?Utf-8?B?QnJ5YW4=?= Microsoft Access Forms 3 20th Feb 2006 07:30 PM
Populate multiple comboboxes with same lists meansean Microsoft Excel Programming 0 5th Apr 2004 10:30 AM
Populate multiple comboboxes with same lists Sean M. Microsoft Excel Programming 1 5th Apr 2004 09:41 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:36 AM.