<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>C#</title><link>http://forums.asp.net/37.aspx</link><description>Discussions/Questions about the C# language. &lt;a href="http://aspadvice.com/SignUp/list.aspx?l=13&amp;c=23" target="_blank"&gt;Email List&lt;/a&gt;</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: help about avoiding duplication...</title><link>http://forums.asp.net/thread/3276345.aspx</link><pubDate>Mon, 06 Jul 2009 08:56:51 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3276345</guid><dc:creator>tapanrami@hotmail.com</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3276345.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=37&amp;PostID=3276345</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;Fetch the data from the database table in the form of Data Reader and then compair each value with newly genearted value. if both match then generate new value&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: help about avoiding duplication...</title><link>http://forums.asp.net/thread/3275283.aspx</link><pubDate>Sun, 05 Jul 2009 10:41:26 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3275283</guid><dc:creator>mohit1122</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3275283.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=37&amp;PostID=3275283</wfw:commentRss><description>&lt;p&gt;thanx....that really helped..&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: help about avoiding duplication...</title><link>http://forums.asp.net/thread/3274898.aspx</link><pubDate>Sat, 04 Jul 2009 18:39:07 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3274898</guid><dc:creator>abdelnaby</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3274898.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=37&amp;PostID=3274898</wfw:commentRss><description>&lt;p&gt;&lt;font color="#000080"&gt;Random RandomClass = new Random();&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font color="#000080"&gt;while(true)&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font color="#000080"&gt;{&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font color="#000080"&gt;int RandomNumber = RandomClass.Next(); &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font color="#000080"&gt;if (!IsExistInDatabase(RandomNumber) )&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font color="#000080"&gt;{&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font color="#000080"&gt;InsertIntoDataBase(RandomNumber);&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font color="#000080"&gt;break;&lt;br /&gt;}&lt;br /&gt;&lt;/p&gt;&lt;/font&gt;
&lt;p&gt;&lt;font color="#000080"&gt;&lt;/font&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;font color="#000080"&gt;}&lt;/font&gt;&lt;/p&gt;</description></item><item><title>Re: help about avoiding duplication...</title><link>http://forums.asp.net/thread/3274660.aspx</link><pubDate>Sat, 04 Jul 2009 12:53:21 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3274660</guid><dc:creator>mohit1122</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3274660.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=37&amp;PostID=3274660</wfw:commentRss><description>&lt;p&gt;it must not be sequential....and i know to achieve this i have to serch the database but the problem is that if the random number generated is already in the database, how can i make it to generate another number until the right one is generated&amp;nbsp; ....i think a loop structure could be used but i dont know how?&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: help about avoiding duplication...</title><link>http://forums.asp.net/thread/3274047.aspx</link><pubDate>Fri, 03 Jul 2009 22:05:23 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3274047</guid><dc:creator>jimmy q</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3274047.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=37&amp;PostID=3274047</wfw:commentRss><description>&lt;p&gt;&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="/Themes/fan/images/icon-quote.gif"&gt; &lt;strong&gt;mohit1122:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;&lt;/p&gt;&lt;p&gt;i want a value of 4 figures which is randomly generated by&lt;/p&gt;&lt;p&gt;&lt;font color="#000080"&gt;Random RandomClass = new Random();&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font color="#000080"&gt;int RandomNumber = RandomClass.Next();&lt;/font&gt;&lt;/p&gt;&lt;p&gt;to be inserted into a table but avoiding duplication...&lt;/p&gt;&lt;p&gt;if the random value generated is already present in the table then i want it to calculate another value and so on until there is no duplication..&lt;/p&gt;&lt;p&gt;&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;/p&gt;&lt;p&gt;First of all, if you are going to limit it to 4 digits which means 0 - 9999 that is only 10,000 individual unique values so at some point you will clash.&lt;/p&gt;&lt;p&gt;If this is acceptable then the second question, is does the number have to be random or can it be sequential, that is you will get 1 2 3 4 5 ... and so on.&lt;/p&gt;&lt;p&gt;If it can be a sequential number then you can rely on the database to do this. Set up an integer column and enable the SEED with an increment on 1. &lt;/p&gt;&lt;p&gt;What this does is on each insertion the database will assign a incremented value of 1 from the previous value.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;If it must not be sequential then you can continue using the Random class but you will need to check the database to see the integer is not used yet.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description></item><item><title>help about avoiding duplication...</title><link>http://forums.asp.net/thread/3273949.aspx</link><pubDate>Fri, 03 Jul 2009 19:32:15 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3273949</guid><dc:creator>mohit1122</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3273949.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=37&amp;PostID=3273949</wfw:commentRss><description>&lt;p&gt;hi..&lt;/p&gt;&lt;p&gt;i want a value of 4 figures which is randomly generated by&lt;/p&gt;&lt;p&gt;&lt;font color="#000080"&gt;Random RandomClass = new Random();&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font color="#000080"&gt;int RandomNumber = RandomClass.Next();&lt;/font&gt;&lt;/p&gt;&lt;p&gt;to be inserted into a table but avoiding duplication...&lt;/p&gt;&lt;p&gt;if the random value generated is already present in the table then i want it to calculate another value and so on until there is no duplication..&lt;br /&gt;&lt;/p&gt;</description></item></channel></rss>