Tutorials
Resources
Forum
Communities
Interview
Jobs
Projects
Offshore Development
Silverlight Tutorials
|
Mentor
|
Code Converter
|
Articles
|
Code Factory
|
Computer Jokes
|
Members
|
Peer Appraisal
|
IT Companies
|
Bookmarks
|
Revenue Sharing
|
Prizes & Awards
My Profile
Sign In
Register
AdSense Revenue
Active Members
Today
Deepika Harida...
(114)
Abraham Kuriak...
(101)
shekhar
(81)
Last 7 Days
UmaShankar
(1211)
ANIL PANDEY
(659)
Deepika Harida...
(534)
more...
New Feature:
Community Sites
:
Create your own .NET community website and start earning from Google AdSense !
It's Free !
How to retrieve populated datatable from sql server
Posted Date: 04 May 2008 Resource Type:
Code Snippets
Category:
Databinding
Posted By:
Rekha
Member Level:
Gold
Rating:
Points
: 10
using System.Data;
using System.Data.SqlClient
// Returns a DataTable, based on the command passed
// the SqlCommand object we wish to execute
// a DataTable populated with the data
// specified in the SqlCommand object
public static DataTable GetDataTable(SqlCommand cmd)
{
try
{
// create a new data adapter based on the specified query.
SqlDataAdapter da = new SqlDataAdapter();
//set the SelectCommand of the adapter
da.SelectCommand = cmd;
// create a new DataTable
DataTable dtGet = new DataTable();
//fill the DataTable
da.Fill(dtGet);
//return the DataTable
return dtGet;
}
catch (SqlException ex)
{
MessageBox.Show(ex.Message);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Responses
No responses found. Be the first to respond and make money from
revenue sharing program
.
Feedbacks
Popular Tags
What are tags ?
Search Tags
Sign In
(No tags found.)
Post Feedback
This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must
Sign In
to post a response.
Next Resource:
How To bind data With the help odbc by coding
Previous Resource:
How to do Paging with Repeater control
Return to Discussion Resource Index
Post New Resource
Category:
Databinding
Post resources and
earn money
!
Related Resources
How to Get Errors in dataset
Enable and Disable a Control by Binding to another Control
How To bind data With the help odbc by coding
How to do Paging with Repeater control
Manually bind controls to Binding Source
dotNet Slackers
BizTalk Adaptors
Web Design
web conferencing
Contact Us
Privacy Policy
Terms Of Use