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 16 1636
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" <mi***************@equityhouse.co.uk> 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
Nah,
didnt make any difference not disposing of the dataset
so im still as stuck as i was before
"EricJ" <er********@ThiSbitconsult.be.RE> wrote in message
news:40*********************@news.skynet.be... 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" <mi***************@equityhouse.co.uk> 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
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" <mi***************@equityhouse.co.uk> 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
my strconn looks like this
Dim strConn As String =
"server=Gringotts;uid=*****;pwd=*****;database=len der"
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]" <gk******@hotmail.com> wrote in message
news:u1****************@TK2MSFTNGP10.phx.gbl... 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" <mi***************@equityhouse.co.uk> 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
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" <mi***************@equityhouse.co.uk> 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=len der"
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]" <gk******@hotmail.com> wrote in message news:u1****************@TK2MSFTNGP10.phx.gbl... 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" <mi***************@equityhouse.co.uk> 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
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" <er********@ThiSbitconsult.be.RE> wrote in message
news:40*********************@news.skynet.be... 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" <mi***************@equityhouse.co.uk> 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=len der"
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]" <gk******@hotmail.com> wrote in message news:u1****************@TK2MSFTNGP10.phx.gbl... 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" <mi***************@equityhouse.co.uk> 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 > >
EricJ
got it working (id missed a line - apologies)
it works fine in both XP and Win2k
Thanks for your help
Mike
"EricJ" <er********@ThiSbitconsult.be.RE> wrote in message
news:40*********************@news.skynet.be... 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" <mi***************@equityhouse.co.uk> 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=len der"
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]" <gk******@hotmail.com> wrote in message news:u1****************@TK2MSFTNGP10.phx.gbl... 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" <mi***************@equityhouse.co.uk> 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 > >
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
Cor,
I've already counted my rows from the dataset, and in both xp and 2k it
returned the correct value
I dispose of my dataadapter and my dataset as they are no longer used and I
presume they use memory
so I dispose of them for efficiency
Mike
"Cor" <no*@non.com> wrote in message
news:uT****************@TK2MSFTNGP11.phx.gbl... 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
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
..net will do that for you normally (if they are no longer needed)
"Mike Fellows" <mi***************@equityhouse.co.uk> wrote in message
news:z63%b.984$44.428@newsfe1-win... Cor,
I've already counted my rows from the dataset, and in both xp and 2k it returned the correct value
I dispose of my dataadapter and my dataset as they are no longer used and
I presume they use memory so I dispose of them for efficiency
Mike
"Cor" <no*@non.com> wrote in message news:uT****************@TK2MSFTNGP11.phx.gbl... 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
hey cor :)
you are absolutely right, but
my colegues have had a lot of unexplainable bound combo problems. I got
everyone working w a bigger version of that 'suske and wiske' class and
since then no probs.
(I like to put a lot of things in there ;p )
"Cor" <no*@non.com> wrote in message
news:OH****************@TK2MSFTNGP10.phx.gbl... 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
i used "lender"
"Cor" <no*@non.com> wrote in message
news:OH****************@TK2MSFTNGP10.phx.gbl... 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
> i used "lender"
Not "Lender" as in your displaymember?
Cor
Yes, I believe you are correct although I have seen situations where I
wasn't connected and also for some reason didn't get an error. Strange but
true.
At any rate, I have used the method of counting rows returned since I
started working with XML files as data sources. I find it a quick way to
determine if I am at least getting anything back.
--
Gerry O'Brien
Visual Developer .NET MVP
"Cor" <no*@non.com> wrote in message
news:uT****************@TK2MSFTNGP11.phx.gbl... 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
This is bizarre. I can do a succesful display on 2K or XP.
--
Gerry O'Brien
Visual Developer .NET MVP
"Mike Fellows" <mi***************@equityhouse.co.uk> 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=len der"
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]" <gk******@hotmail.com> wrote in message news:u1****************@TK2MSFTNGP10.phx.gbl... 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" <mi***************@equityhouse.co.uk> 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
This discussion thread is closed Replies have been disabled for this discussion. Similar topics
4 posts
views
Thread by Kathy |
last post: by
|
1 post
views
Thread by John |
last post: by
|
1 post
views
Thread by Jassim Rahma |
last post: by
|
5 posts
views
Thread by Rich |
last post: by
|
2 posts
views
Thread by Matt |
last post: by
| | |
2 posts
views
Thread by Wingot |
last post: by
| | | | | | | | | | |