Best way to bound a webcontrol

F

Fabiano

pls,

Reading some technical article i got that i should use DataReader than
Dataset, 'cause it improves performance. But i can't (or i don't know how)
to bound a DataReader to a webcontrol, such as a ComboBox.

Is there's a way i can do this? Someone can send me an example?

Another question, visually is there a way i can bound visually a data object
to a web control, auch as OleDbCommand? Or i need to create a DataAdapter,
than a Dataset?

Tks in adv.

Fabiano
 
J

Jeffrey Tan[MSFT]

Hi Fabiano,

Based on my understanding, you want to use *DataReader class to do
databinding to your webform control.

Yes, if you only want to retrieve your database data and display them, use
DataReader will be more fast. You may do databinding like this:

SqlConnection cnn = new
SqlConnection("server=(local);database=pubs;Integrated Security=SSPI");
SqlCommand cmd = new SqlCommand("select * from authors", cnn);
cnn.Open();
DataGrid1.DataSource = cmd.ExecuteReader(CommandBehavior.CloseConnection);
DataGrid1.DataBind();

If you want to do the virtual databinding at design-time for your control,
you may drag a SqlDataAdapter(From ToolBox "Data" tab page) to the
designer. Then, select correct database connection.(There will be a wizard
form for your to complete all these steps.) After you finished the wizard,
a SqlConnection component will already generated for you. Then you can
right click the SqlDataAdapter component in the designer form, "Generate
DataSet".

At last, you can select your web control, in the property browser, you can
select datasource in the DataSource property.

==================================
Please apply my suggestion above and let me know if it helps resolve your
problem.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
J

Jeffrey Tan[MSFT]

Hi Fabiano,

Does my reply makes sense to you? Do you still have any concern?

Please feel free to let me know, I will help you. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,951
Messages
2,570,113
Members
46,698
Latest member
alexxx

Latest Threads

Top