If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > Populating a Datalist control

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-21-03, 17:53
sgskumar sgskumar is offline
Registered User
 
Join Date: Jun 2003
Posts: 8
Smile Populating a Datalist control

Hi,

I am trying to populate a datalist control with the data in the sql server. Below is the code :

Public con As New ADODB.Connection
Public AdoRoles As New ADODB.Recordset

con.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=name;Password=password;Initial Catalog=Spotlight;Data Source=SQL"

AdoRoles.Open "SELECT RoleType FROM Role ORDER BY RoleType", con

Set DataList1.DataSource = AdoRoles
Set DataList1.RowSource = AdoRoles
DataList1.DataField = RoleType
DataList1.ListField = RoleType
DataList1.Refresh

The Problem is when I run the code the datalist control is empty. I dont know what I am doing wrong. Please help me.

Thanks
Reply With Quote
  #2 (permalink)  
Old 07-23-03, 09:34
dbadelphes dbadelphes is offline
Registered User
 
Join Date: Feb 2003
Location: Montreal, Canada
Posts: 117
Re: Populating a Datalist control

Just take out the following line and it should work...

Set DataList1.DataSource = AdoRoles


Quote:
Originally posted by sgskumar
Hi,

I am trying to populate a datalist control with the data in the sql server. Below is the code :

Public con As New ADODB.Connection
Public AdoRoles As New ADODB.Recordset

con.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=name;Password=password;Initial Catalog=Spotlight;Data Source=SQL"

AdoRoles.Open "SELECT RoleType FROM Role ORDER BY RoleType", con

Set DataList1.DataSource = AdoRoles
Set DataList1.RowSource = AdoRoles
DataList1.DataField = RoleType
DataList1.ListField = RoleType
DataList1.Refresh

The Problem is when I run the code the datalist control is empty. I dont know what I am doing wrong. Please help me.

Thanks
__________________
Steve
Reply With Quote
  #3 (permalink)  
Old 07-23-03, 13:28
sgskumar sgskumar is offline
Registered User
 
Join Date: Jun 2003
Posts: 8
Red face Re: Populating a Datalist control

Quote:
Originally posted by dbadelphes
Just take out the following line and it should work...

Set DataList1.DataSource = AdoRoles
I tried that, didnt work. The datalist is still empty.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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