VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Code to accept the details of Customer , Update ,Delete them & to Save in the Database . Also to vi

by Madan . Nawale (1 Submission)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Fri 19th July 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Code to accept the details of Customer , Update ,Delete them & to Save in the Database . Also to view the list of Customers`

Rate Code to accept the details of Customer , Update ,Delete them & to Save in the Database . Also to vi



Dim comCustomers As Command
Dim rstCustomers As Recordset
Dim intStatus As Integer
Dim intPosition As Integer

Private Sub Form_Load()

Set conOnlineBanking = New Connection
Set comCustomers = New Command
Set rstCustomers = New Recordset

With conOnlineBanking
    .ConnectionString = "User Id = sa ;password=;Data Source = mr1-pdc-ddr;Initial Catalog = OnlineBanking"
    .Provider = "SQLOLEDB"
    .Open
End With

comCustomers.ActiveConnection = conOnlineBanking

rstCustomers.Open "select * from customers", conOnlineBanking, adOpenDynamic, adLockOptimistic

Call FillList
Call Display

End Sub

Private Sub cmdNew_Click()
 For Each Control In Customers
     If TypeOf Control Is TextBox Then
        Control.Text = " "
        txtCode.SetFocus
     End If
 Next
 rstCustomers.AddNew
    'Call Allow

End Sub

Private Sub cmdSave_Click()

    intStatus = 1
    
    For Each Control In Customers
        
        If TypeOf Control Is TextBox Then
            
            If Control.Text = " " Then
                
                MsgBox "Incomplete data"
                intStatus = 0
               
                Exit For
            End If
        
        End If

    Next

    If intStatus = 1 Then
    
    rstCustomers("cCustomerCode") = txtCode.Text
    rstCustomers("vName") = txtName.Text
    rstCustomers("cTelephoneNo") = txttelNo.Text
    rstCustomers("cFaxNo") = txtFaxNo.Text
    rstCustomers("cEmailId") = txtEmailId.Text
    rstCustomers("ddate") = txtDate.Text
    rstCustomers("cAmount") = txtAmount.Text
    rstCustomers.Update

    Call FillList
    'Call Disallow

    End If

End Sub

Private Sub cmdUpdate_Click()

    'Call Allow

End Sub
Private Sub cmdDelete_Click()

    rstCustomers.Delete
       
    rstCustomers.MoveNext
    
    If rstCustomers.EOF Then rstCustomers.MoveLast
    
    Call Display
    Call FillList
    
End Sub





Private Sub lstCustomerName_Click()

    intPosition = lstCustomerName.ListIndex
    
    rstCustomers.MoveFirst
    
    rstCustomers.Move intPosition
    
    Call Display
    
End Sub

Private Sub Display()

    txtCode = rstCustomers("cCustomerCode")
    txtName = rstCustomers("vName")
    txttelNo = rstCustomers("cTelephoneNo")
    txtFaxNo = rstCustomers("cFaxNo")
    txtEmailId = rstCustomers("cEmailId")
    txtDate = rstCustomers("ddate")
    txtAmount = rstCustomers("cAmount")
        
End Sub

Private Sub FillList()

    lstCustomerName.Clear
    rstCustomers.Requery
    rstCustomers.MoveFirst
        
        Do While Not rstCustomers.EOF
            lstCustomerName.AddItem rstCustomers("cCustomerCode")
            rstCustomers.MoveNext
        Loop
        
        rstCustomers.MoveFirst
        
        Call Display
        
End Sub




Download this snippet    Add to My Saved Code

Code to accept the details of Customer , Update ,Delete them & to Save in the Database . Also to vi Comments

No comments have been posted about Code to accept the details of Customer , Update ,Delete them & to Save in the Database . Also to vi. Why not be the first to post a comment about Code to accept the details of Customer , Update ,Delete them & to Save in the Database . Also to vi.

Post your comment

Subject:
Message:
0/1000 characters