datareader in c#
I am having a real problem with something that seems so easy. I have an ASP.NET file which I have a seperate c# file. In my c# file I would like to connect to my database which is a SQL Server express 2005 db with web developer 2005.
Once connected to my db I would like to retrieve a value 'contact name' to a variable which I can then use in my insert. I started to use things like -
SqlDataSource contacts = new SqlDataSource();
contacts.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
contacts.SelectCommand = "SELECT contactName FROM tblContacts WHERE contactID = @tmpContactID";
What I cannot seem to do is make this into a datareader and add to a variable (string).
I am banging my head against a wall now so please help.