vb application to oracle connection

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shreshta
    New Member
    • Sep 2007
    • 15

    vb application to oracle connection

    this is the code i wrote for my application to retrieve values,delete values,update values and insert values...

    i am havin doubt in delete and retrieve snippets whether it works right. and deletion should ask for the primarykey which is traderid over here and on getting it,it retrieves all details for the particular user and deletes it. i couldnt check out right now as i dont have connection.

    'adodc control

    Private Sub Adodc1_WillMove (ByVal adReason As ADODB.EventReas onEnum, adStatus As ADODB.EventStat usEnum, ByVal pRecordset As ADODB.Recordset )

    End Sub

    'reset all values/clear the values

    Private Sub Command9_Click( )

    firstname.Text = ""
    middlename.Text = ""
    lastname.Text = ""
    sex.Text = ""
    city.Text = ""
    state.Text = ""
    country.Text = ""
    mailid.Text = ""
    userid.Text = ""
    password.Text = ""
    traderid.Text = ""

    End Sub


    'retrieve contents
    Private Sub Command1_Click( )

    Dim sql As String
    sql = "select * from trader;"
    'specify format of SQL result and assisgn to ADODC
    Adodc1.CommandT ype = adCmdText
    Adodc1.RecordSo urce = sql
    Adodc1.Refresh

    End Sub


    'insert records

    Private Sub Command3_Click( )

    Adodc1.Recordse t.AddNew

    Adodc1.Recordse t.Fields("first name") = firstname.Text
    Adodc1.Recordse t.Fields("middl ename") = middlename.Text
    Adodc1.Recordse t.Fields("lastn ame") = lastname.Text
    Adodc1.Recordse t.Fields("sex") = sex.Text
    Adodc1.Recordse t.Fields("city" ) = city.Text
    Adodc1.Recordse t.Fields("state ") = state.Text
    Adodc1.Recordse t.Fields("count ry") = country.Text
    Adodc1.Recordse t.Fields("maili d") = mailid.Text
    Adodc1.Recordse t.Fields("useri d") = userid.Text
    Adodc1.Recordse t.Fields("passw ord") = password.Text
    Adodc1.Recordse t.Fields("trade rid") = traderid.Text

    Adodc1.Recordse t.Update

    MsgBox "Data inserted and updated"
    End Sub

    'delete records by retriving the details using traderid details and deleting.

    sql = "select firstname,middl ename,lastname, sex,city,state, country,mailid, panno,userid,pa ssword,traderid from trader where traderid=&trade rid;"
    If Adodc1.Recordse t.EditMode = adEditDel Then
    If MsgBox("Do you really want to delete ?", vbYesNo) = vbYes Then
    Adodc.Recordset .Delete
    End If
    End If
    Unload Me

    End Sub
  • KevinADC
    Recognized Expert Specialist
    • Jan 2007
    • 4092

    #2
    Wrong forum, hopefully a moderator will move your thread shortly.

    Comment

    • shreshta
      New Member
      • Sep 2007
      • 15

      #3
      Originally posted by KevinADC
      Wrong forum, hopefully a moderator will move your thread shortly.
      hello mr.kevin, i asked whether anyone cud help me out in viewing the records and also deletion and updation..i asked to verify and help me out not tell anythin like your thread will be moved. please help me out people

      Comment

      • hariharanmca
        Top Contributor
        • Dec 2006
        • 1977

        #4
        Invert this code
        [CODE=vb]
        firstname.Text = Adodc1.Recordse t.Fields("first name")
        middlename.Text = Adodc1.Recordse t.Fields("middl ename")
        lastname.Text = Adodc1.Recordse t.Fields("lastn ame")
        --------------------
        -------------
        ---------
        --[/CODE]

        use four command button and write code for
        Move Next
        Move Previous
        Move First
        Move Last

        Now, by clicking the commands you can view record in text box

        To delete

        ADODC1.RecordSe t.Delete (which is the text boxes)

        [CODE=vb]
        Adodc1.Recordse t.Edit

        Adodc1.Recordse t.Fields("first name") = firstname.Text
        Adodc1.Recordse t.Fields("middl ename") = middlename.Text
        Adodc1.Recordse t.Fields("lastn ame") = lastname.Text
        Adodc1.Recordse t.Fields("sex") = sex.Text
        Adodc1.Recordse t.Fields("city" ) = city.Text
        Adodc1.Recordse t.Fields("state ") = state.Text
        Adodc1.Recordse t.Fields("count ry") = country.Text
        Adodc1.Recordse t.Fields("maili d") = mailid.Text
        Adodc1.Recordse t.Fields("useri d") = userid.Text
        Adodc1.Recordse t.Fields("passw ord") = password.Text
        Adodc1.Recordse t.Fields("trade rid") = traderid.Text

        Adodc1.Recordse t.Update[/CODE]

        This is the concept. Try your best.

        Comment

        • QVeen72
          Recognized Expert Top Contributor
          • Oct 2006
          • 1445

          #5
          Hi,

          After reading the TradeID, u have to find it in the ADODC, if found, then Delete, and then Refresh.. Something like this :

          [code=vb]
          ADODC1.RecordSe t.MoveFirst
          ADODC1.RecordSe t.Find "tradeID=" & TradeID
          If Not ADODC1.RecordSe t.EOF Then
          ADODC1.RecordSe t.Delete
          ADODC1.RecordSe t.Refresh
          ADODC1.RecordSe t.MoveFirst
          Else
          Msgbox "Trade ID Not Found"
          End If
          [/code]

          REgards
          Veena

          Comment

          Working...