Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

newbie - late bind datalist doesn't populate

 
   Database Help (Home) -> Visual Basic -> ADO RSS
Next:  Extremely slow connection to linked tables  
Author Message
Newbee Adam

External


Since: Feb 14, 2005
Posts: 3



(Msg. 1) Posted: Mon Feb 14, 2005 11:09 am
Post subject: newbie - late bind datalist doesn't populate
Archived from groups: microsoft>public>vb>database>ado (more info?)

Private Sub cmdLookUpGroupInfo_Click()
In the code below, I succesfully was able to bind and polpulate a text box
with my select statement. But I need multiple table rows to be populated so I
cannot use the text box. So I am trying to use the datalistbox or the
datagrid (I have selcted them in project components and dragged them on the
form) since they can show multirow row results from a select query. But I am
totally new and can not get them to be populated with my select statement but
my text box populates fine. What am I missing here. I would like to know how
to use the datalist or datagrid. I am sure the answer is obvious, but this
vb6 ado book is giving me a headache and I am stuck^$#^$#!!!!]
please help!!!
Dim rs As New ADODB.Recordset
Dim strGroupLookUpCriteria As String

'Put text box value into varabiable for SQL statement
strGroupLookUpCriteria = Trim(txtGroupLookUpCriteria)

'Set and open the recordset
rs.ActiveConnection = moconn
rs.CursorType = adOpenDynamic
rs.CursorLocation = adUseClient
rs.Open ("SELECT * FROM GroupLookUp WHERE groupnumber Like '" &
strGroupLookUpCriteria & "'")

'bind text box txtProd to field "prod"
Set datalistGroupInfo.DataSource = rs 'problem I had connection here instead
of the recordsource
datalistGroupInfo.DataField = "Prod"
datalistGroupInfo.ListField = "Prod"

'Set DataGridGroupInfo.DataSource = rs 'problem I had connection here
instead of the recordsource
'DataGridGroupInfo.DataField = "Prod"

Set Text1.DataSource = rs 'problem I had connection here instead of the
recordsource
Text1.DataField = "Prod"


........
--
Adam S

 >> Stay informed about: newbie - late bind datalist doesn't populate 
Back to top
Login to vote
Mark J. McGinty

External


Since: Aug 31, 2003
Posts: 30



(Msg. 2) Posted: Wed Feb 16, 2005 9:08 am
Post subject: Re: newbie - late bind datalist doesn't populate [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Sorry about your headache (it's an occupational hazard, buy the big bottle
of Tylenol.) For DataList you need to set the RowSource and ListField
properties, then call the ReFill method. DataSource binds the selected
value to a row, RowSource is used to populate it with prospects.

btw, Under ordinary circumstances I'd mention the inherent dangers of your
code (begging for a SQL injection attack,) and that a construct you're using
(Dim rs as new...) will tend to leak resources, but you seem inundated,
so... feel free to ask when you are ready.

Good Luck,
Mark



"Newbee Adam" wrote in message

 >
 >
 >
 > Private Sub cmdLookUpGroupInfo_Click()
 > In the code below, I succesfully was able to bind and polpulate a text box
 > with my select statement. But I need multiple table rows to be populated
 > so I
 > cannot use the text box. So I am trying to use the datalistbox or the
 > datagrid (I have selcted them in project components and dragged them on
 > the
 > form) since they can show multirow row results from a select query. But I
 > am
 > totally new and can not get them to be populated with my select statement
 > but
 > my text box populates fine. What am I missing here. I would like to know
 > how
 > to use the datalist or datagrid. I am sure the answer is obvious, but this
 > vb6 ado book is giving me a headache and I am stuck^$#^$#!!!!]
 > please help!!!
 > Dim rs As New ADODB.Recordset
 > Dim strGroupLookUpCriteria As String
 >
 > 'Put text box value into varabiable for SQL statement
 > strGroupLookUpCriteria = Trim(txtGroupLookUpCriteria)
 >
 > 'Set and open the recordset
 > rs.ActiveConnection = moconn
 > rs.CursorType = adOpenDynamic
 > rs.CursorLocation = adUseClient
 > rs.Open ("SELECT * FROM GroupLookUp WHERE groupnumber Like '" &
 > strGroupLookUpCriteria & "'")
 >
 > 'bind text box txtProd to field "prod"
 > Set datalistGroupInfo.DataSource = rs 'problem I had connection here
 > instead
 > of the recordsource
 > datalistGroupInfo.DataField = "Prod"
 > datalistGroupInfo.ListField = "Prod"
 >
 > 'Set DataGridGroupInfo.DataSource = rs 'problem I had connection here
 > instead of the recordsource
 > 'DataGridGroupInfo.DataField = "Prod"
 >
 > Set Text1.DataSource = rs 'problem I had connection here instead of the
 > recordsource
 > Text1.DataField = "Prod"
 >
 >
 > .......
 > --
 > Adam S

 >> Stay informed about: newbie - late bind datalist doesn't populate 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Bind Variables ADO - Oracle - Hello, I am trying to call a stored procedure in Oracle from my Visual Basic code. I am using MS ADO 2.7 library to do this. Everytime I call the stored procedure it creates a new entry for the SP in the global sql area as if it is not using bind..

newbie - how to resize column MSFlexGrid - newbie - how to resize column MSFlexGrid I do not see in properties, maybe I am blind, how to change column width. I would like to set it to just resize automatically to widest field of the column, of corse. can I, may I!!!??? thanks -- Adam S

Sever-side cursor return NOTHING??(newbie) - Hi, I try to use dataenv object. I add new connection (jet 3.51 provider with Biblio example) and then add command (all use server side cursor) and then drag command in to Form . However, when I run the project (vb6 sp5 WinXP sp1), I got nothing in the..

runtime error 3021 and user permissions - I have a VB6 application that uses ADO 2.7 to access an Access2000 database. I have found on Windows XP and 2000, that if the user is not part of the administrators group, they receive: "runtime error 3021. Either BOF or EOF is true, or the current ...

updatable ado-recordset - Hi, In the code below i have an updatable ado-recordset. However it is not working how i thought it would be. Maybe someone can help me out here? The global connection (Thanks to Brendan): Option Compare Database Option Explicit Public mconn As..
   Database Help (Home) -> Visual Basic -> ADO All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]