I want to pull some data from an SQL database, so that i can display it in on a literal control (which has a 'text' member).
I'm not sure how to do this, because i'm getting stuck with the SQLDataReader.
Any help would be greatly appreciated.
Printable View
I want to pull some data from an SQL database, so that i can display it in on a literal control (which has a 'text' member).
I'm not sure how to do this, because i'm getting stuck with the SQLDataReader.
Any help would be greatly appreciated.
Done it i was missing the Read() method call. :rolleyes:
Using the nchar SQL field type.Code:void SetNickName(int IDNumber, Literal DestLiteral)
{
SqlConnection myConnection = new SqlConnection("server=GEORGE;database=MyDB;Trusted_Connection=yes");
SqlCommand myCommand = new SqlCommand("select NickName from people where id=" + IDNumber, myConnection);
myConnection.Open();
SqlDataReader dr = myCommand.ExecuteReader();
dr.Read();
DestLiteral.Text = dr.GetString(0);
myConnection.Close();
}