System.Data.SqlClient.SqlConnection _cn = new System.Data.SqlClient.SqlConnection();
_cn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["DatabaseConnectionString"].ConnectionString;
_cn.Open();
System.Data.SqlClient.SqlCommand SelectCommand = new System.Data.SqlClient.SqlCommand("SELECT AgentName FROM [Manager Database].dbo.tblAgents WHERE (AgentID = 45)", _cn);
System.Data.SqlClient.SqlDataReader dtr;
dtr = SelectCommand.ExecuteReader();
if (dtr.Read())
label1.Text=dtr["AgentName"].ToString();
_cn.Close();
|