hey..my name is marluke..
i want to know the code of Save, Edit and Delete
using visual basic 6 and the database is Ms Access
does any body wants to help me?
please i really want to know and learn
visual basic..
thanks for helping
LuKeZ
hey..my name is marluke..
i want to know the code of Save, Edit and Delete
using visual basic 6 and the database is Ms Access
does any body wants to help me?
please i really want to know and learn
visual basic..
thanks for helping
LuKeZ
Hi Luke...Welcome to Daniweb Friend :)
visit this following links to learn how to connect access with vb.
- VB And Ms Access
- VB6 Database Guide
Then try it, if u get some problem post it here.
Happy Coding Friend :)
hi marluke
if u use a data control ur code will be :
data1.recordset.update ' for save
data1.recordset.edit ' for edit
data1.recordset.delete ' for delete
data1.recordset.refresh ' for delete
:) :D :*
:)) (^^^)
EDIT
Module1.setConnectProc
Set globRSrecordset = New ADODB.Recordset
globRSrecordset.Open "SELECT * FROM table_name WHERE BkTitle='" & Trim(txtTitle) & "'", strVar, adOpenKeyset, adLockOptimistic
With globRSrecordset
If Not .EOF Then
!BkTitle = txtTitle
!Author = txtAuthor
!BkRefNo = Val(txtBkRefNo)
!TrnDate = txtDate
MsgBox "Record Updated!", vbInformation, "Updated Existing Record"
.Update
.MoveLast
End If
.Close
End With
DELETE
connectModule.setConnectProc
Set globRSrecordset = New ADODB.Recordset
globRSrecordset.Open "SELECT * FROM table_name WHERE BkTitle='" & Trim(txtTitle) & "'", strVar, adOpenKeyset, adLockOptimistic
With globRSrecordset
If Not .EOF Then
.Delete
End If
.Close
End With
Module1
Public globDBConnect As ADODB.Connection
Public globRSrecordset As ADODB.Recordset
Public strVar As String
Public Sub setConnectProc()
Set globDBConnect = New ADODB.Connection
strVar = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Location\DatabseName.accdb;Persist Security Info=False"
globDBConnect.Open strVar
End Sub
If you are using Access 2007 use .accdb
If you are using Access 2003 use .mdb
where i will write above code ??
You will add it to a module (.bas)
Please open your own thread, we will help from there. This thread is 4 years old.
dsave_Click(Index As Integer)
Set rs = New ADODB.Recordset
With rs
If .RecordCount = 0 Then
.AddNew
MsgBox "Succesfully Save", , "Save Complete"
End If
!EID = Text1
!Fname = txtfname
!Lname = txtlname
!MI = txtMI
!Age = txtage
!UserName = txtuser
rs.Update
End With
Set rs = Nothing
view
End Sub
Help me with that code bec. when i compile it this line
rs.Open "Select * from Registration where EID=" & CInt(Text1.Text) & "", cn, 1, 2
is will say method or data member not found the "Cint(Text1.Text)
Private Sub cmdsave_Click(Index As Integer)
Set rs = New ADODB.Recordset
rs.Open "Select * from Registration where EID=" & CInt(Text1.Text) & "", cn, 1, 2
With rs
If .RecordCount = 0 Then
.AddNew
MsgBox "Succesfully Save", , "Save Complete"
End If
!EID = Text1
!Fname = txtfname
!Lname = txtlname
!MI = txtMI
!Age = txtage
!UserName = txtuser
rs.Update
End With
Set rs = Nothing
view
End Sub
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.