PLEASE HELP ME. THIS CODE WILL RETRIEVE THE SEQUENCE YOU MADE. AND WILL OUTPUT IN THE TEXBOX IN THE NEXT FORM. BUT MY PROBLEM IS THAT IT DOES NOT RETRIEVE/GIVE THE GENERATED SEQUENCE. FOR SHORT NO OUTPUT T__T . PLEASE HELP.

 Public Sub getJO()
        Dim oradb As String = "Provider=OraOLEDB.Oracle; Data Source=TRAVELMATE-PC/XE;User Id=cj;Password=me;"
        Dim cn As New OleDbConnection
        Dim cm As New OleDbCommand
        Try
            cn.ConnectionString = ConfigurationManager.ConnectionStrings("mysys.My.MySettings.ConnectionString").ConnectionString()
            Dim conn As New OleDb.OleDbConnection(oradb)
            cn.Open()
            cm.Connection = cn
            cm.CommandText = "select ID_SEQ.currval from dual"
            cm.CommandType = CommandType.Text
            Dim dr As OleDbDataReader = cm.ExecuteReader()
            If dr.Read() Then

                Form4.TextBox1.Text = dr.Item(0).ToString

            End If
        Catch ex As Exception
        End Try
        cn.Close()
    End Sub

Couple things:

  1. Titles that start with "PLEASE HELP ME" are annoying.
  2. Using all caps in bold for your post is even more annoying.

Now, as for your code. I don't understand what a "sequence" is supposed to be; it looks like your putting one result into a text box. Try explaining, in more detail, what exactly you are trying to do, and what your current code is doing wrong.

sorry sir for annoying you.
I am working with sequence to generate id number for my system. The code will display the generated sequence in a textbox. And my problem is that, the sequence doesnt appear.

I am experiencing problem in the code of line 12..

The way I normally do this would be a dataset.

Example:

    Dim con As New OleDbConnection(ConfigurationManager.ConnectionStrings("mysys.My.MySettings.ConnectionString").ConnectionString())
    con.Open()
    Dim dat As New OleDbDataAdapter(New OleDbCommand("SELECT MAX(ID_SEQ) FROM dual", con))
    Dim ds As New DataSet

    dat.Fill(ds, "Max")

    If ds.Tables("Max").Rows.Count > 0 Then
        Form4.TextBox1.Text = ds.Tables("Max").Rows(0).Item(0)
    End If
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.