|
ini contoh programnya:
Dim ECON As ADODB.Connection
Dim RS1 As ADODB.Recordset ============================================
'ini
maslahnya
'pas aku add data
pertama masuk tapi pas aku add lagi gak masuk
datanya
Private Sub Command1_Click() 'ini tombol add If Len(Trim(Text1.Text)) < 5 Or Len(Trim(Text1.Text)) > 5 Then MsgBox ("ID tidak boleh <5 ATAU >5") Text1.SetFocus Text1.Text = " " Exit Sub End If If Text2.Text = " " Then MsgBox ("diisi...") Text2.SetFocus Exit Sub End If If Len(Trim(Text1.Text)) = 5 And Text2.Text <> " " Then ok If RS1.RecordCount > 0 Then MsgBox ("Data Sudah Ada") Text1.SetFocus Exit Sub End If On Error Resume Next RS1.AddNew RS1.Fields("CD_BRG") = Text1.Text RS1.Fields("NM_BRG") = Text2.Text RS1.Update End If BLANK 'ini fungsi kosongkan End Sub =============================================
'ini fungsinya
Private Sub BLANK() Text1.Text = " " Text2.Text = " " Text1.SetFocus End Sub
===================================================
Private Sub Form_Load()
Set ECON = New ADODB.Connection
With ECON .ConnectionString = "provider=sqloledb;user id=EMC;password=rers123;persist security info=true; initial catalog=tester;data source=rio-csumum" .Open If Not .State = adStateOpen Then MsgBox "Tidak dapat membuat hubungan ke database" End If End With End Sub
=============================================
'ini fungsi buka
recordsetnya
Private Sub ok() Dim sql As String Set RS1 = New ADODB.Recordset sql = "select * from jns_brg where cd_brg='" & Trim(Text1.Text) & "'" With RS1 .ActiveConnection = ECON .CursorLocation = adUseClient .CursorType = adOpenDynamic .LockType = adLockOptimistic .Source = sql .Open End With End Sub
Untuk keluar dari millis ini, kirim email kosong ke: [EMAIL PROTECTED] YAHOO! GROUPS LINKS
|
- Re: [Programmer-VB] TANYA UPDATE RECORD rima
- Re: [Programmer-VB] TANYA UPDATE RECORD Gunawan doang
- [Programmer-VB] Re: TANYA UPDATE RECORD Muhammad Rivai Andargini
