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
Appukuttan
(94)
Abhi
(72)
Babu Akkandi
(63)
Last 7 Days
Appukuttan
(619)
Babu Akkandi
(470)
divya
(321)
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
Author:
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
Bind DropDownList from DataBase , Using c#
Bind using collections
Manually bind controls to Binding Source
Fill a DropDownList with files in a directory using c#
dotNet Slackers
BizTalk Adaptors
Web Design
Contact Us
Privacy Policy
Terms Of Use