TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Set The Gridview's Datasource Property And Simply Call The Databind Method
Padmanaban Pugalenthi
Aug 12
2016
Code
520
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
New Microsoft Word D
SqlConnection Conn =
new
SqlConnection(
"Data Source=Localhost\\SQLEXPRESS;Initial Catalog=Flash2;Integrated Security=True;"
);
SqlDataReader rdr = null;
string commandString =
"SELECT * FROM USER_MASTER"
;
try
{
Conn.Open();
SqlCommand Cmd =
new
SqlCommand(commandString, Conn);
rdr = Cmd.ExecuteReader();
MasterCustView.DataSource = rdr;
MasterCustView.DataBind();
}
catch
(Exception ex)
{
// Log error
}
finally
{
if
(rdr != null)
{
rdr.Close();
}
if
(Conn != null)
{
Conn.Close();
}
}
SQL Server