Crud Program Using Vb

Topics: Ring, Mathematics, Programming language Pages: 4 (323 words) Published: October 19, 2012
ample CRUD Project using VB6
Sample CRUD Project using VB6

Private Sub Adodc1_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)

Adodc1.Caption = "Rec. " & Adodc1.Recordset.AbsolutePosition & " of " & Adodc1.Recordset.RecordCount

End Sub

Private Sub cmdAdd_Click()

Dim pkey As Integer

If mfblnDuplicateFound = True Then
'the same record already exists
MsgBox "The same record already exists! Operation cannot proceed." GoTo ExitHere
End If

pkey = Adodc1.Recordset.RecordCount + 1


Adodc1.Recordset.Fields(0).Value = pkey
Adodc1.Recordset.Fields(1).Value = Text1.Text
Adodc1.Recordset.Fields(2).Value = Text2.Text


Exit Sub

End Sub

Private Function mfblnDuplicateFound() As Boolean

Dim objCon As ADODB.Connection
Dim objCmd As ADODB.Command
Dim objRst As ADODB.Recordset

Dim blnFlag As Boolean

Set objCon = New ADODB.Connection
Set objCmd = New ADODB.Command
Set objRst = New ADODB.Recordset

objCon.ConnectionString = Adodc1.ConnectionString
objCon.Open objCon.ConnectionString

objCmd.ActiveConnection = objCon
objCmd.CommandText = "SELECT * FROM " & Adodc1.RecordSource
objRst.CursorLocation = adUseClient
objRst.Open objCmd, , adOpenForwardOnly, adLockReadOnly

blnFlag = False

'check if author name already exists

If objRst.RecordCount > 0 Then
Do While objRst.EOF = False
If objRst.Fields(1).Value = Text1.Text Then
blnFlag = True
Exit Do
End If
End If

'If Adodc1.Recordset.BOF = False And Adodc1.Recordset.EOF = False Then ' Adodc1.Recordset.MoveFirst
' Do While Adodc1.Recordset.EOF = False
' If Adodc1.Recordset.Fields(1).Value = Text1.Text Then
' blnFlag = True
' Exit Do
' End If
' Adodc1.Recordset.MoveNext
' Loop
'End If

mfblnDuplicateFound = blnFlag

End Function

Private Sub...
Continue Reading

Please join StudyMode to read the full document

You May Also Find These Documents Helpful

  • Library System Using Vb Essay
  • Program Using Assembly Language Essay
  • Library System Using Vb Essay
  • Program Essay
  • Program Essay
  • Essay on Program
  • Programs Essay
  • Employee Assistance Program proposal Essay

Become a StudyMode Member

Sign Up - It's Free