473,396 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

sqldatasource to fill a datatable

Can I use a sqlDataSource to fill a datatable in code? How?
Thanks,
T
Aug 16 '07 #1
2 5191
Hi Tina,
SqlDataSource is component used for databinding. If you need to fill
DataTable in your code use SqlDataAdapter instead.

DataTable table = new DataTable();
using (SqlConnection conn = new SqlConnection(myConnectionString))
{
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = new SqlCommand("some database query", conn);
adapter.Fill(table);
}

Best regards,
Ladislav

"Tina" wrote:
Can I use a sqlDataSource to fill a datatable in code? How?
Thanks,
T
Aug 17 '07 #2
I'm aware of what you are saying.
My question stands.
T

"Ladislav Mrnka" <La***********@discussions.microsoft.comwrote in message
news:61**********************************@microsof t.com...
Hi Tina,
SqlDataSource is component used for databinding. If you need to fill
DataTable in your code use SqlDataAdapter instead.

DataTable table = new DataTable();
using (SqlConnection conn = new SqlConnection(myConnectionString))
{
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = new SqlCommand("some database query", conn);
adapter.Fill(table);
}

Best regards,
Ladislav

"Tina" wrote:
>Can I use a sqlDataSource to fill a datatable in code? How?
Thanks,
T

Aug 17 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Sam_Chou | last post by:
How to SqlDataSource become DataTable example: my GridView's datasource is SqlDataSource but i need DataTable (DataSet) so...can SqlDataSource convert to DataTable? thx a lot
8
by: cider123 | last post by:
In Design mode I open up the SqlDataSource (Configure Data Source) I go all the way through until the last page where you "Test Query" and it takes about 2 seconds to return a response. My...
1
by: VB Programmer | last post by:
I have a SqlDataSource I setup on an ASP.NET 2.0 webform. I setup the SELECT statement and it has 1 parameter, @ProductId. How do I, using VB.NET, store the results of that SELECT statement...
1
by: tom c | last post by:
I am using Visual Web Developer 2005 Express Edition. I created a SQLDataSource just by draging the control to the form and filling in the blanks in the wizard. In code I need to use the...
2
by: WebMatrix | last post by:
Hello, Stored procedure returns results of 3 different queries. On ASP.NET 2.0 page I have a SqlDataSource control with SelectCommand equals this stored procedure name. I want to be able to...
1
by: Per W. | last post by:
Hi, is there som other way to do this? i only want the result from the select statement so i can use it in my code. I dont need the gridview, but this is the only way i got it to work. The...
6
by: Ken Fine | last post by:
I'm using SQLDataSource, which generates some kind of dataset, and then I attach that datasource to various data display controls such as DataList and repeater which loop through to the end of the...
2
by: kevinpond | last post by:
I have a Gridview displaying the results of a stored procedure. The stored procedure is constantly changing so the columns displayed in the data grid are constantly changing. I'd like to give...
1
by: jobs | last post by:
I have a GRIDVIEW I have bound to an OBJECTDATASOURCE that has the select pointing to a class method that uses ADO to grab a dataset from SQL Server Stored Procedure. One of the columns that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.