Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Set The Gridview's Datasource Property And Simply Call The Databind Method
WhatsApp
Padmanaban Pugalenthi
Aug 12
2016
572
0
0
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
Up Next
Set The Gridview's Datasource Property And Simply Call The Databind Method