Crud Program Using Vb

Only available on StudyMode
  • Topic: Ring, Mathematics, Programming language
  • Pages : 4 (323 words )
  • Download(s) : 179
  • Published : October 19, 2012
Open Document
Text Preview
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.AddNew

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

Adodc1.Recordset.Update

ExitHere:
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
objRst.MoveFirst
Do While objRst.EOF = False
If objRst.Fields(1).Value = Text1.Text Then
blnFlag = True
Exit Do
End If
objRst.MoveNext
Loop
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...
tracking img