By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,959 Members | 1,139 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,959 IT Pros & Developers. It's quick & easy.

datagrid and a datalist

lee123
100+
P: 556
i have a book i have bought from amazon.com called "visual basic 6.0 advanced topics" and in one of the examples it has something i have been trying to figure out for awhile it has a datalist and a datagrid the datalist i have filled with the database northwind database (customers tbl) and the datagrid i wanted to fill with the (orders tbl) i have set all the properties to what this book says but when i run the code it gives. it keeps giving me an error: to see if i got this code the way i should have it please look at this and tell me what im doing wrong.

the erorr it gives me is:(syntax error FROM clause) from the adodc2
adodc2 on mine is for the datagrid
adodc1 is for the datalist

i tried this (my Code)
Expand|Select|Wrap|Line Numbers
  1. Private Sub DataList1_Click()    
  2.     Dim cstrsql As String
  3.     cstrsql = "select * from customers " & " where orderID = " & " '  " & DataList1.BoundText & " ' " 
  4.    Adodc2.RecordSource = cstrsql
  5.     Adodc2.Refresh
  6. End Sub
  7.  
in this book there code is
Expand|Select|Wrap|Line Numbers
  1. private sub dblname_click()
  2.  
  3.   dim pstrsql as string
  4.  pstrsql = "select * from tblpayrolldetail " & " where fldemployeeid = " & " ' " & _
  5.     dblname.boundtext & " ' "
  6. adpayrolldetail.recordsource = pstrsql
  7. adpayrolldetail.refresh
  8.  
  9. end sub
  10.  
there are two adodc controls in theres called

payroll master ( for the datalist)
payroll detail ( for the datagrid)

I need to understand how i can apply this example in the book to a project im doing for me....

lee123
Jan 10 '08 #1
Share this Question
Share on Google+
8 Replies


Ali Rizwan
100+
P: 927
Are you using this code for filling datagrid or data list or list view controls?
If yes will i tell you another command to fill them which is easier an quick.
if no then also tell me what are you trying to do?
Actually i am not much expert in sql but know a bit.

Regards
>> ALI <<
Jan 11 '08 #2

lee123
100+
P: 556
i am trying to fill the datagrid from the information i select from the datagrid for instance if i select a person from the datalist his information would fill in the datagrid and no one else's


lee123
Jan 11 '08 #3

QVeen72
Expert 100+
P: 1,445
Hi,

What are "BoundColumn" and "DataField" for the datalist.
Is Data List populated properly..?

I guess, you are Filling details of Customer name and ID in DataList,
but in Query (datalist_Click) you have queried for OrderID.... Does not match here..

Regards
Veena
Jan 11 '08 #4

lee123
100+
P: 556
this is where i get confused in this book it gives the second example (not the first) there bound column they call (bound text) if that's the same as bound column. they put the employeeID and then used it in a select statement to select the matching payroll details.(this is for there datalist which is named - dblName)

i tried to use the northwind database for my example in mine the datalist bound column is set to the orderID maybe that's wrong (huh) and the datafield is set to customername. so when i click it the information about that customer would show up in the datagrid. but as you can see it didn't work. if you look at the northwind database and tell me why or if i did something i wasn't suppose to or even a better way that would do just fine. im trying to understand this SQL but it's trickier than the vb language it self.

oh just to note in the northwind database in the customer table it has an customerID. but when you go to the order table it only has a orderID and when you go to the order detail table it has only the order detail id. i guess i was looking for the customerID in the Order table but it's not there.

lee123
Jan 11 '08 #5

QVeen72
Expert 100+
P: 1,445
Hi,

What you can do is :
Fill DataList with CustomerName(ListField) and CustomerID (BoundColumn)
and In Click event, Query Orders for the Selected Customer:

"Select * From Orders Where CustomerID = '" & Datelist1.BoundText & "'"
Populate ADO/Datagrid with the above query

Regards
Veena
Jan 11 '08 #6

lee123
100+
P: 556
tell me something QVeen72,

in the ado's i have on the form

adodc1, i have set the connectionstring with the northwind database. right?
and the recordsource to the customers table. right?

then for:

adodc2, i have set the connectionstring with the northwind database. right?
and the recordsource to the orders table right?

the datalist i have set it's boundcolumn to customerID & the listfield to customersname

ok the datagrid i have set the datasource to adodc2 right?

and i did what you said and nothing? it keeps giving me an erorr:(syntax erorr in from clause)

lee123
Jan 11 '08 #7

lee123
100+
P: 556
i have figured it out

but one question can i use a dropdown box for this as well to populate the datagrid and the rest of the textboxes instead of a datalist and use the code i have now

lee123
Jan 12 '08 #8

QVeen72
Expert 100+
P: 1,445
Hi,

Instead of DataList, use a DataCombo...
Both work with same functionalty with slight difference..

Regards
Veena
Jan 12 '08 #9

Post your reply

Sign in to post your reply or Sign up for a free account.