ADODB replacing values in your DB

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chuckzter
    New Member
    • Oct 2007
    • 56

    ADODB replacing values in your DB

    Hey guys,

    I would like to know how to replace values in your database via ADODB.

    Example:
    (I would want to replace the value LOCATION of ID 1001 which is Oliver to Laguna.)

    ID NAME LOCATION
    1001 | Oliver | Quezon City
    1002 | Paul | Laguna

    I've made 2 buttons, 1 is to search the other one is to insert. Is my logic right? Or is there another way?

    Here are my codes:

    (FOR SEARCHING)
    Set cn = New ADODB.Connectio n
    Set rs = New ADODB.Recordset
    cn.Open "DSN=db1"
    b = (InputBox("Ente r Student Number"))
    Set rs = cn.Execute("sel ect * from Student_Info")
    While rs.EOF = False And rs.BOF = False
    If b = rs.Fields("Stud ent_No") Then
    Text3.Text = rs.Fields("Stud ent_No")
    MsgBox ("user found")
    Exit Sub
    Else
    rs.MoveNext
    End If
    Wend
    MsgBox ("user not found")


    (FOR INSERTING):

    Set cn = New ADODB.Connectio n
    Set rs = New ADODB.Recordset
    cn.Open "DSN=db1"
    Set rs = cn.Execute("sel ect * from Student_Info")
    While rs.EOF = False And rs.BOF = False
    If rs.Fields("Stud ent_No") = Text3.Text Then
    er = Combo1.Text
    et = Text3.Text
    -->'Set rs = cn.Execute("Ins ert into Student_Info (course) values ('" & Combo1.Text & "' ) where rs.fields("Stud ent_No")=text3. text")
    -->'Set rs = cn.Execute("Upd ate Student_Info SET course = er Where Student_No = et;")
    rs.Fields("cour se") = er
    MsgBox ("pasok")
    Exit Sub
    Else
    rs.MoveNext
    End If
    Wend

    End Sub

    Legend:

    (-->) Neither one of these codes does what i want them to.


    Is there a problem of syntax or logic, me and my group are kinda stuck at this point. Please help.

    Thanks in advance.
  • chuckzter
    New Member
    • Oct 2007
    • 56

    #2
    i tried

    Private Sub Command5_Click( )
    Set cn = New ADODB.Connectio n
    Set rs = New ADODB.Recordset
    cn.Open "DSN=db1"
    b = (InputBox("Ente r Student Number"))
    Set rs = cn.Execute("sel ect * from Student_Info where Student_No = '" & b & "'")
    If (rs.EOF) And (rs.BOF) Then
    MsgBox "Record does not exist!", vbCritical
    Else
    rs.Fields("cour se") = Combo1.Text
    MsgBox ("user found")
    Exit Sub
    End If
    MsgBox ("user not found")
    End Sub



    But i encounter the error "Current recordset does not support updating. This may be a limitation of the provider, or of the selected lock type."

    What should i do?

    Comment

    • Ali Rizwan
      Banned
      Contributor
      • Aug 2007
      • 931

      #3
      Originally posted by chuckzter
      Hey guys,

      I would like to know how to replace values in your database via ADODB.

      Thanks in advance.
      Here is an atachment for replacing any field.
      Check it
      GOODLUCK
      ALI
      Attached Files

      Comment

      • chuckzter
        New Member
        • Oct 2007
        • 56

        #4
        This is great ali but i think this is ADODC.

        We are only permitted to use ADODB.

        Comment

        • Ali Rizwan
          Banned
          Contributor
          • Aug 2007
          • 931

          #5
          Originally posted by chuckzter
          This is great ali but i think this is ADODC.

          We are only permitted to use ADODB.
          Hello,
          I think if you use adodc it will easy for you because it is quick and easy to buid database with it.
          If you are a bigginer then it will better than adodb
          else
          i ll demonstrate another project for you.
          GOODLUCK
          ALI

          Comment

          • chuckzter
            New Member
            • Oct 2007
            • 56

            #6
            Sorry but we are only permitted to use ADODB, yes ADODC is easy but me and my friends must follow what our professor told us. It's a pain, i know.

            Comment

            • Ali Rizwan
              Banned
              Contributor
              • Aug 2007
              • 931

              #7
              Originally posted by chuckzter
              Sorry but we are only permitted to use ADODB, yes ADODC is easy but me and my friends must follow what our professor told us. It's a pain, i know.
              Hello,
              What kind of error you are recieving?
              Please tell.
              GOODLUCK
              ALI

              Comment

              • chuckzter
                New Member
                • Oct 2007
                • 56

                #8
                "Current recordset does not support updating. This may be a limitation of the provider, or of the selected lock type."

                Comment

                • jrtox
                  New Member
                  • Sep 2007
                  • 89

                  #9
                  Originally posted by chuckzter
                  Hey guys,

                  I would like to know how to replace values in your database via ADODB.

                  Example:
                  (I would want to replace the value LOCATION of ID 1001 which is Oliver to Laguna.)

                  ID NAME LOCATION
                  1001 | Oliver | Quezon City
                  1002 | Paul | Laguna

                  I've made 2 buttons, 1 is to search the other one is to insert. Is my logic right? Or is there another way?

                  Here are my codes:

                  (FOR SEARCHING)
                  Set cn = New ADODB.Connectio n
                  Set rs = New ADODB.Recordset
                  cn.Open "DSN=db1"
                  b = (InputBox("Ente r Student Number"))
                  Set rs = cn.Execute("sel ect * from Student_Info")
                  While rs.EOF = False And rs.BOF = False
                  If b = rs.Fields("Stud ent_No") Then
                  Text3.Text = rs.Fields("Stud ent_No")
                  MsgBox ("user found")
                  Exit Sub
                  Else
                  rs.MoveNext
                  End If
                  Wend
                  MsgBox ("user not found")


                  (FOR INSERTING):

                  Set cn = New ADODB.Connectio n
                  Set rs = New ADODB.Recordset
                  cn.Open "DSN=db1"
                  Set rs = cn.Execute("sel ect * from Student_Info")
                  While rs.EOF = False And rs.BOF = False
                  If rs.Fields("Stud ent_No") = Text3.Text Then
                  er = Combo1.Text
                  et = Text3.Text
                  -->'Set rs = cn.Execute("Ins ert into Student_Info (course) values ('" & Combo1.Text & "' ) where rs.fields("Stud ent_No")=text3. text")
                  -->'Set rs = cn.Execute("Upd ate Student_Info SET course = er Where Student_No = et;")
                  rs.Fields("cour se") = er
                  MsgBox ("pasok")
                  Exit Sub
                  Else
                  rs.MoveNext
                  End If
                  Wend

                  End Sub

                  Legend:

                  (-->) Neither one of these codes does what i want them to.


                  Is there a problem of syntax or logic, me and my group are kinda stuck at this point. Please help.

                  Thanks in advance.
                  chuckzter, Muzta Repa!

                  I Really dont spoonfeed student, but your excepted coz youre a filipino..
                  By the way im in Sta.maria bulacan now, But i Graduated in STI-College ORMOC, ORMOC city.


                  Just download the attachment i made.
                  Its not the same the way you Design your project but it can help you.

                  Regards
                  Ervin
                  Attached Files

                  Comment

                  • chuckzter
                    New Member
                    • Oct 2007
                    • 56

                    #10
                    Hey bro, thanks for the sample zip. I'll analyze it and try to apply it to our system.


                    Off-topic:

                    STI-Southwoods bro, i'm in my 3rd yr now taking up computer science.

                    Comment

                    • jrtox
                      New Member
                      • Sep 2007
                      • 89

                      #11
                      Originally posted by chuckzter
                      Hey bro, thanks for the sample zip. I'll analyze it and try to apply it to our system.


                      Off-topic:

                      STI-Southwoods bro, i'm in my 3rd yr now taking up computer science.
                      Hello

                      OK, Good luck

                      Regards
                      Ervin

                      Comment

                      Working...