Step 1:
First of all add appSettings tag in web.config file under configuration tag
--------appSettings------------
add key="cn" value="workstation id=SQL8;packet size=4096;user id=user1;password=password1;data source=671.15.417.21;initial catalog=DBNews; Connection Timeout=120;"
--------appSettings------------
Step 2:
Add namespace given below.
using System.Data
using System.Data.SqlClient;
Step 3:
Add below code under partial class
SqlConnection con;
SqlCommand cmd;
SqlDataAdapter adp;
DataSet ds;
Step 4:
Call below code at Page Load event
con = new SqlConnection(ConfigurationManager.AppSettings["cn"]);
String sql = "select * from tbl_adminuser";
cmd = new SqlCommand(sql, con);
adp = new SqlDataAdapter(cmd);
ds = new DataSet();
adp.Fill(ds, "tbl_adminuser");
Step 5:
Show User password on the page.
TextBox1.Text=ds.Tables[0].Rows[0]["Password"].ToString();
15 years ago
No comments:
Post a Comment