Welcome :Guest
Congratulations!!!

Top 5 Contributors of the Month
david stephan
yasminpriya
Ram
Gaurav Pal
christianasteves

### Generate Random Numbers

SQL Server has a built-in function that generates a random number, the RAND() mathematical function. The RAND math function returns a random float value from 0 through 1.

### Update with unique random generated values.

Hi there, I have an issue with an update of a column with unique random generated values, using SQL 2005. What I want to achieve is to create unique username for a list of let's say 1000 rows. My approach, which may be wrong, is as follows: to create a view to retrieve a random generated number of 7 digits; to use a function that retrieves the number from the view and checks if it is unique in the table or not (if it is, the number is returned, if it is not, a new one will be generated and so on); to update the table using that random generated number. The problem is that it does not work. It does not generate unique numbers, not all the times (you have to test by running the code few times). I suspect it is something with the update, but not sure how to solve it. Here are the steps to reproduce the problem. Create the table: CREATE TABLE [dbo].[TB_Temp]( [ID] [int] IDENTITY(1,1) NOT NULL, [ADM_USERNAME] [nvarchar](7) COLLATE Latin1_General_CI_AS NULL, ) ON [PRIMARY] Add some test rows: DECLARE @i INT SET @i = 0 WHILE @i <= 1000 BEGIN INSERT INTO TB_TEMP (ADM_USERNAME) VALUES ('') SET @i = @i +1 END Create the view to random generate 7 digits numbers: CREATE VIEW vw_RandNumberForAdminUserName AS SELECT ROUND((9999999 - 1000000 - 1) * RAND() + 1000000, 0) AS RandNumber Create the function to retrieve the unique 7 digits number: CREATE FUNCTION [dbo].[fn

### How to show random information with C# from a SQL Database?

I have to do the following in my web page.  Any advice and how to do this please with C# I have a table where I have a column for different states (NY, NJ, etc).  People can join the group (in my page) for each state (the state where they live).  So I have to display the newest members for each state. So the way it should work is, every time the page is refreshed/reloaded it should show the state name as a header text and the first 5 newest members for that state.  This should be random, for example initially when the page is loaded say it will show state: New York and the 5 recent members like Stacy, Laura, Mike, Sam, Mathew. Then when the page is refreshed it will show another state like State: california and the recent 5 members All the information comes from the database How should I do this?

### Select random 10 records in sql server 2005 in terms of time

Hello,i have a query that select random records in access database in terms of time : "SELECT TOP 10 * FROM Tbl ORDER BY Rnd(-10000000*TimeValue(Now())*[ID])"now i wish to convert this query for using in sql server 2005 such that return random records in term of time

### SharePoint Designer random issues

I have designed a workflow which sends an email to the "Created By" user account.  Out of 124 submissions, 10 have errored out showing that the user account is not correct.   Domain\user points to email account user@company.com However, there are times which the workflow sends the email to "LastName ; FirstName MI." instead... Any ideas as to why this would be happening?

### Datareader: Set multiple random images into appropriate image field

Hi, first of all, sorry if my title isn confusing as i dont really sure the specify description regarding what i wan to do.   Now what i trying to do is, I getting 5 random images from the database, this is the code for me to get random 5 records from database: Dim command As New SqlCommand("SELECT TOP 5 Description,Image,ImageID FROM Properties ORDER BY ImageID", con)  and with the help of image handler to display it to 5 Images components i put in the page, lets say name it "Image1" to "Image5". Now the question is, how do i assign the 5 diff imageID into the 5 image components? Lets say i wan my Image1's imageID is 1, and Image2's imageID is 2. What im doing now is assigning all the same imageID to all 5 images. Below is how i assign the imageIDDim reader As SqlDataReader reader = command.ExecuteReader If reader.HasRows = True Then While reader.Read Image1.ImageUrl = "GetThumbnail.aspx?ImageID=" & reader("ImageID") & " " Image2.ImageUrl = "GetThumbnail.aspx?ImageID=" & reader("ImageID") & " " Image3.ImageUrl = "GetThumbnail.aspx?ImageID=" & reader("ImageID") & " " Image4.ImageUrl = "GetThumbnail.aspx

### Search results page showing random characters instead of item's description

I have an email-enabled document library that a few Japanese people email PDF files into (all external to the company). When I search for any PDF file sent from particular email addresses, the search results page displays random characters instead of the item's description. Here is an example: From Screen shots These characters don't appear for all email senders, just some of them. Our MOSS site is in English and we don't have any language packs installed. The PDF file contents are also in English. Can anyone point me towards a solution for this?

### create RandomNumber from 1 - 100 by prssed random button

How I can create RandomNumber from 1 - 100 by prssed random button   can you help me as soon as possibel I have an assignment   Thanks Yousf

Some users are getting random access denied messages. They will be working in a site, click on a link, and get access denied. Come back a couple minutes later and everything will be fine. Is it possible to fine tune logging to capture these access denied messages? Thanks for taking the time.

### XCOPY deployment of WCF application produces random exceptions

We are using a simple self-developed XCOPY-like tool for copying the binaries etc. of a WCF application directly into the physical folder of a virtual directory on IIS. After the deployment the application randomly throws an excetion ("The ObjectContext instance has been disposed and can no longer be used for operations that require a connection"). I know that this is EF related (we are using EF for data access purposes within our WCF services) but donÄt think it has anything to do with EF.However, the exception occurs absolutely without any pattern. Starting our app multiple times results in the excetion sometimes but it succeeds immediately afterwards. I even restarted the IIS windows service but the same phenomenon still exists afterwards.When I use the "Publish" dialog from VS2008 for the deployment everything is fine. However, we need to do the deployment through our script as we have a staging location between our dev and prod environments.What do we have to to in order to make a successfull and reliable XCOPY deployment and get rid of this strange behaviour?

### Linq Random selection

I've build a linq query.But i want a random selection so its not always ID : 1,2,3,4,5,6 How can i randomize this var? I like to bind it to a repeater. //TagCloud:        Random rand = new Random();        var tc1 = from i in JumpTide.cms.menu.GetMenuItems(32)                                      select new                    {                        ID = i.ID,                        PageID = i.PageID.Value,                        Name = i.Name,                        PageName = JumpTide.cms.paginas.GetPages(i.ID, 1).FirstOrDefault().tblContent.header

### how to use random generate number with linq

how to use random generate number with linqthanks in Advance:)

### get random number less than x

hi how can i get a random number less than x. Best Regards. morteza

### Equivalent C# function for this random access read for this VB6 function?

I'm having a problem reading a block of bytes into an array from a file read (random access).  Instead, in C#, it seems I can only read byte by byte and not a block of byte.  I want to create a string array that is 500 cells in capacity but each cell is 10 bytes wide.  how do i do this?I have  written the function in Vb6 and maybe someone can tell me the fs.Read (code) for the C# equivalent.In Vb6, I declaredPrvate Type WFM  points(500) as String * 10   // This will create an string array of 500 cells but the KEY here is each cell is 10 bytes wide fixed!End type

### Bug in System.Random [ .Net Framework 4 ]

Hi all, try this code below:var rand = new Random(); while (rand.Next(minValue: 0, maxValue: 5) < 5) { /* do something */ } // causes block forever // this line is never called Is it a bug???

### 64 bit Strong Random function

i want to generate 64 Bit random number (Range between 2^50 and 2^64) in C#
 Categories:
 ASP.Net Windows Application .NET Framework C# VB.Net ADO.Net Sql Server SharePoint Silverlight Others All