I am a newbie trying to work on project. I do not have any C# experience but do have some VB experience.
I have a table that Has two Columns. Employee_ID, Last_Name
I need to find a way to pull out the Last_Name and use it further down in my code to place the value into a XML file. The XML portion is already created and working. I just do not know the systax to pull out the Last_Name Column out the table.
Any help would be great. I have tried googleing it but i am getting very far.
Thanks in advance
I have a table that Has two Columns. Employee_ID, Last_Name
I need to find a way to pull out the Last_Name and use it further down in my code to place the value into a XML file. The XML portion is already created and working. I just do not know the systax to pull out the Last_Name Column out the table.
Any help would be great. I have tried googleing it but i am getting very far.
Code:
// query
using (SqlConnection conn = new SqlConnection("Data Source=servername;Initial Catalog=dbname;User Id=UID;Password=PSW;"))
{
conn.Open();
string query = string.Format("SELECT * FROM dbo.MORvision2PML WHERE Employee_ID = '1959001831'", Employee_ID);
SqlCommand cmd = new SqlCommand(query, conn);
using (SqlDataReader sdr = cmd.ExecuteReader())
{
if (!sdr.Read())
throw new ApplicationException("Record not found");
while (sdr.Read())
{
//string LastName = (string)sdr["B1_Last_Name"];
}
Thanks in advance