random waarde uit tabel access

Status
Niet open voor verdere reacties.

savant11

Gebruiker
Lid geworden
7 jan 2008
Berichten
153
Hoi allen,

heb nu dit:

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.OleDb;
//using System.Data.OleDB; 

namespace CustomDataReaders
{
    class Program
    {
        Random RAND = new Random();
        static void Main(string[] args)       
        {

           
            //Create a connection
    OleDbConnection m_cnADONewConnection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\meetSysteem.mdb");
    //open the connection
    m_cnADONewConnection.Open();
    //Create a command object.
    OleDbCommand myCommand = m_cnADONewConnection.CreateCommand();
    //Specify a query
    myCommand.CommandText = "Select TOP 1 plank_nr FROM  plank ORDER BY Rnd(plank_nr) ";// (plank_nr) LIMIT 1"; //+ RAND();// limit 1 " ;
      
            
            // myCommand.CommandText = "Select TOP 1  plank_nr FROM  plank WHERE rnd(plank_nr)";// ORDER BY kast_nr()" ;
    //Create a DataReader for the command
    OleDbDataReader myDataReader = myCommand.ExecuteReader();


    //Display the resulting Data
    while (myDataReader.Read())
   {
       Random ran = new Random();
       //Console.WriteLine(ran.Next("kast_nr"));
      // Console.ReadLine();

       //Console.WriteLine("{0}   ", myDataReader["kast_nr"]);
      // Console.WriteLine(" plank:{0}   ",((Random)myDataReader["plank_nr"]));
       Console.WriteLine(" plank:{0}   ", myDataReader["plank_nr"]);        
   }

 
    //Close the DataReader.
    myDataReader.Close();
    //Close the connection
    m_cnADONewConnection.Close();

 
    //Keep the console open until a keystroke.
    Console.ReadKey(true);

           



        }

       
    }
}

Maar krijg steeds dezelfde waarde terug.

Iemand verstand van? Alvast bedankt.

Niels.
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan