Results 1 to 2 of 2

Thread: Getting a string from an SQL database

  1. #1

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051

    Getting a string from an SQL database

    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.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  2. #2

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051

    Re: Getting a string from an SQL database

    Done it i was missing the Read() method call.

    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();
     }
    Using the nchar SQL field type.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width