• WSNight

    WSNight

    @wsnight

    Viewing 15 replies - 151 through 165 (of 169 total)
    Author
    Replies
    • in reply to: -214 type errors (VB6) #534951

      Actually I alread have a trap like that. Here is my code

      Private m_recLogin As ADODB.Recordset
      Private mcnn As ADODB.Connection

      Private Const UPDATE_CANCELLED As Long = -2147217842
      Private Const ERRORS_OCCURRED As Long = -2147217887

      Private Sub cmdOK_Click()

      ‘Validate Passwords
      ‘Makes sure the password in both boxes are the same
      If txtPassword2.Text = txtPassword1.Text Then
      MoveToRecord (adDoAddNew)
      Else
      MsgBox “Invalid Password.”, vbExclamation + vbOKOnly
      txtPassword1.SetFocus
      End If

      End Sub

      Private Sub Form_Load()

      Set m_recLogin = datLogin.Recordset
      Set mcnn = m_recLogin.ActiveConnection

      End Sub

      Private Sub MoveToRecord(intDirection As String)

      On Error GoTo MoveToRecord_Err

      Select Case intDirection

      ‘Adds User name and Password to Database
      Case adDoAddNew
      m_recLogin.AddNew “SOID”, txtAlias

      End Select

      MoveToRecord_Exit:
      frmTotals.Show
      Exit Sub

      MoveToRecord_Err:
      If mcnn.Errors.Count > 0 Then
      For Each errCurrent In mcnn.Errors
      MsgBox errCurrent.Number & “–” & _
      errCurrent.Description
      Next errCurrent
      mcnn.Errors.Clear
      Else
      Select Case Err.Number
      Case UPDATE_CANCELLED, ERRORS_OCCURRED
      ‘Do Nothing
      Case Else
      Err.Raise Err.Number, Err.Source, Err.Description
      End Select
      End If
      Resume MoveToRecord_Exit

      End Sub

      I assume what I did with the errCurrent is what you are talking about.

    • Thanks for sending that example, I will take a look at it, and store it for future need. But I actually got it to write to the database yesturday afternoon. I do appreciate the help you’ve been giving though.

    • I must be. Even when I take out all the code, and have it so just the ADO control is bound to the text boxes i want it won’t update the database. I will take a look at that article and see if it helps out. Thanks for the help.

    • My lock type is adLockOptimistic. I don’t really know if that code worked because it didn’t spit any errors at me. This thing is giving me a brain tumor. I’ve used so many sorces to try and figure out how to use this control, and get it to write to the database. Wish I new more about this stuff than I do.

    • yes, datLogin.Recordset is the recordset attached to the ADODataControl. Right now I am using an adOpenDynamic cursor setting. How do I go about testing the errors collection of the connection?

    • I am using an ADO recordset. Here is my code for the ADO recordset.

      Private Sub Form_Load()

      Set m_recLogin = datLogin.Recordset

      End Sub

      Private Sub MoveToRecord(intDirection As Integer)

      On Error GoTo MoveToRecord_Err

      Select Case intDirection

      ‘Adds User name and Password to Database
      Case adRsnAddNew
      m_recLogin.AddNew

      End Select

      MoveToRecord_Exit:
      frmTotals.Show
      Exit Sub

      MoveToRecord_Err:
      Select Case Err.Number
      Case UPDATE_CANCELLED, ERRORS_OCCURRED
      ‘Do Nothing
      Case Else
      Err.Raise Err.Number, Err.Source, Err.Description
      End Select
      Resume MoveToRecord_Exit

      End Sub

    • I get no error what so ever now. It runs through the code without a hitch. It just doesn’t write it to the target table, or any other table. I’ve done some of my own research (as much as one can anyway) and I think in my adRsnAddNew Case I need to list the fields from the table there. Only thing is I’ve tried doing that a number of ways. I can’t figure out how I’m supposed to do it. Thanks for any help provided.

    • I changed it to a long, string, whatever trying to get this thing to write to the database. I tried update, but it didn’t seem to work. I’m not exactly sure why it won’t save to the database, as far as I know it should work.

    • OK. I actually just figured all the validation out, thanks for the help anway though. Now my only problem is that it is not writing to the database. Here is what I have for code now.

      Private Sub cmdOK_Click()

      If txtPassword2.Text = txtPassword1.Text Then
      MoveToRecord (adRsnAddNew)
      Else
      MsgBox “Invalid Password.”, vbExclamation + vbOKOnly
      txtPassword1.SetFocus
      End If

      End Sub

      Private Sub Form_Load()

      Set m_recLogin = datLogin.Recordset

      End Sub

      Private Sub MoveToRecord(intDirection As Integer)

      On Error GoTo MoveToRecord_Err

      Select Case intDirection

      Case adRsnAddNew
      m_recLogin.AddNew
      m_recLogin(“SOID”) = txtAlias
      m_recLogin(“Password”) = txtPassword2

      End Select

      MoveToRecord_Exit:
      frmTotals.Show
      Exit Sub

      MoveToRecord_Err:
      Select Case Err.Number
      Case UPDATE_CANCELLED, ERRORS_OCCURRED
      ‘Do Nothing
      Case Else
      Err.Raise Err.Number, Err.Source, Err.Description
      End Select
      Resume MoveToRecord_Exit

      End Sub

      I think my problem lies in the part of my Case statement. I am not sure why it isn’t writing to the database though.

    • Yes I am

    • Not to sure on how to use the validate function. Is it possible for you to post some sample code so I could work out how to use it for what I’m doing?

    • I got most of it all figured out. I can do the validation either way. Except with the bound text box it is a little different. To validate it the way I’m doing it on the cmdOk_Click function I needed to add (0) at the end of the txtPassword2 to get the options I needed. I will look into doing it the other way. As for the MoveToRecord, I just forgot to call the case that I wanted so that was easy. It now reads
      MoveToRecord(adRsnAddNew)
      Thanks for your help.

    • Ok I got the first error fixed, but I get the same error on the MoveToRecord part of my code. MoveToRecord is just the name of a subroutine, this should call it should it not? Here is my new code.

      Private Sub cmdOK_Click()

      If Forms!frmNewUser.txtPassword2.Value Forms!frmNewUser.txtPassword1.Value Then
      MsgBox “Invalid Password Entered.”, vbExclamation + vbOKOnly
      Forms!frmNewUser.txtPassword1.SetFocus
      ElseIf Forms!frmNewUser.txtPassword2.Value = Forms!frmNewUser.txtPassword1.Value Then
      MoveToRecord

      End Sub

    • I’ll try that out to see how it works. Thanks for your help. I assume that it is generally the same kind of thing for the user name as well. As for the security with the table holding the passwords. The database itself will not be accessed by anyone except the admin, they will also have restricted permissions as well. Anyway thanks for your help.

    • Well I am using VB mostly. The reason I need to have user names added is because there is potential for more users to be added. And as I said I am new to all of VB, I only started learning it probably 1 week ago when I recieved this project. So I’m not exactly sure how to do much, I’ve used whatever resources I could fine, books, help file, whatever I can. So help on anything would be most useful. I can figure the logic behind all of it since I do have experiance in other programming languages. Thanks.

    Viewing 15 replies - 151 through 165 (of 169 total)