Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6686595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:11:23+00:00 2026-05-26T05:11:23+00:00

Hi im creating a program where when the form loads random data will retrieve

  • 0

Hi im creating a program where when the form loads random data will retrieve from the database and my problem is the code for not repeating the data again.
im using vb 2008 and sql database,
programming language : C#

for example:

Data in Database

Word_ID | Word
1 | eye
2 | cheese
3 | mouse

Then form loads it will retrieve random data and display in the label

example output:

cheese

so cheese now will not display on the next random

my code:

SqlConnection conn =
new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\sony\Documents\Visual Studio 2008\Projects\Hangman_Final\Hangman_Final\hangman_db.mdf;Integrated Security=True;User Instance=True");

conn.Open();

SqlCommand command = conn.CreateCommand();
command.CommandText = "SELECT TOP 1 Words from word order by NEWID()";
command.CommandType = CommandType.Text;

SqlDataReader reader = command.ExecuteReader();

// display the results
while (reader.Read())
{
    string output = reader["Words"].ToString();
    label5.Text = output;
}

// close the connection
reader.Close();
conn.Close();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T05:11:23+00:00Added an answer on May 26, 2026 at 5:11 am

    Store words into List<String>. Get an element at random index from the list , print it and remove it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a program that will electronically conjugate verbs in Spanish from their infinitive
I'm creating a program to transfer text from a word document to a database.
I am creating a program that will be installed using the .net installer project.
I am creating a program that needs to store the user's data in encrypted
I'm creating a program that authenticates from a before it runs. I also want
I have been tasked with creating a program that will generate an amortization schedule.
I have been tasked with creating a program what will create take files in
I'm creating a java program that creates a file and fills it with data
This is a C# winforms app. Preface: I am creating a form that will
I am trying to improve my C++ by creating a program that will take

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.