|
-
Apr 21st, 2004, 11:01 PM
#1
Thread Starter
Member
Database question
How do i save some data in a database (in access) and get the information when ever i want????
-
Apr 21st, 2004, 11:11 PM
#2
A search will usually work wonders.
ADO Tutorial
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Apr 21st, 2004, 11:53 PM
#3
Junior Member
hi there,
Regarding the updation and retrieval of data from the database
you need to take care of few points
1.Firstly you need to set connection with the database.
2.open the recordset and write a query
3.Write a procedure for updation and retrieval of data shown below.
Here i m using ADO Connection
Option Explicit
Dim rs As ADODB.Recordset
Dim cn As ADODB.Connection
Private Sub cmdRetrieve_Click()
'****************************************************
' This procedure is used to retrieve data from the database
'****************************************************
Set rs = New ADODB.Recordset
rs.Open "select * from amount", cn, adOpenKeyset, adLockOptimistic
If Not rs.RecordCount = 0 Then
txtname = rs("name")
txtroute = rs("route")
txtyear = rs("year")
Else
MsgBox "No record Exists"
End If
rs.Close
Set rs = Nothing
End Sub
Private Sub cmdsave_Click()
'****************************************************
'This particular event will save the textdata in their respectice fields
'****************************************************
Set rs = New ADODB.Recordset
rs.Open "select * from amount", cn, adOpenKeyset, adLockOptimistic
rs.AddNew
rs("name") = txtname
rs("route") = txtroute
rs("year") = txtyear
rs.Update
MsgBox "The record is saved"
rs.Close
Set rs = Nothing
End Sub
Private Sub Command1_Click()
'*********************************************
'This Statement is used to end the application
'*********************************************
End
End Sub
Private Sub Form_Load()
'*****************************************
'This will provide you with the connection
'*****************************************
Set cn = New ADODB.Connection
Dim strconn As String
strconn = "Dsn=hemant"
cn.Open strconn
End Sub
---Here I need to mention I am using a dsn instead of directly giving the path.
To create a dsn
1 In Setting Click on control panel
2.Then in control panel you will find odbc data sources<click on it>
3.Then in odbc click on configure
a)out there give a dsn name and the reqd details
b) Then Click on select and select the reqd database
For using ado connection go to Project>References and select Microsoft Acticex data objects 2.0 library
if you want any assistance contact at [email protected]
-
Apr 22nd, 2004, 10:23 AM
#4
You may want to use a newer version of ADO than 2.0. The
current version is 2.8, but I would recommend using 2.7 because
it has more bug fixes in it. You can download it from M$. Search
for "MDAC 2.7". Also, don't forget that using a dsn will
depend on how it is set up. It could be machine, user, or file
specific. Also, to create the dsn you need to select the type and
click "New" not configure. Configure is for modifing an existing
dsn.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|