Error !! Can you help ?


Dim Cn As OleDbConnection
Dim Cmd As OleDbCommand

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:inetpubwwwrootStudent.mdb;User ID=Admin;Password=;")
Cn.Open()
CreateStudentIdRandomly()
Catch ex As Exception

End Try
End Sub

Public Sub CreateStudentIdRandomly()

Try

Dim str As String
Dim number As Integer
Dim i As Integer
Dim r As New Random

str = String.Empty
number = 0

--> str = r.Next(100000000, 999999999).ToString()

For i = 0 To 6
If str.Substring(i, 1) = str.Substring(i + 1, 1) Then
If str.Substring(i + 1, 1) = str.Substring(i + 2, 1) Then
CreateStudentIdRandomly()
End If
End If
Next

number = CType(str, Integer)

Cmd = New OleDbCommand("Insert into T values (" & number & ")", Cn)
cmd.ExecuteNonQuery()

Catch ex As StackOverflowException

Finally

CreateStudentIdRandomly()

End Try

End Sub



Hi ,

In the above code while executing at run-time it is throwing an exception (An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll" ) at -->


Can you please give me an idea why it is happening so ?

Advance ThanX for your time & patience.

Thanks,
Kishore

Comments

  • you have called a loop from within itself. or you have tried to create an object from within its own class ike this

    class form1

    f = new form1

    end class
    "Within these countries, the man who was loyal, I rewarded well, who was evil, him I punished well!"

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion