| | |
Urgent Help please in Database
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
You have to copy the code of OpenDatabase as well.
•
•
Join Date: Jun 2007
Posts: 166
Reputation:
Solved Threads: 9
•
•
•
•
Hi Everyone
Please anyone tell me how can I use the following code in vb6 Module.
Dim db As Database
Dim rs As Recordset
Private Sub Form_Load()
Set db = OpenDatabase("C:\MyDatabase.mdb")
End Sub
Thanks in advance
If it exists try the following:
Private Sub Form_Load()
Dim db As Database
Dim rs As Recordset
Set db = OpenDatabase("C:\MyDatabase.mdb")
End Sub
If the above works then it is a case of Scope rule. Get back to me.
Last edited by AV Manoharan; Jul 7th, 2007 at 9:31 am.
•
•
Join Date: Jun 2007
Posts: 10
Reputation:
Solved Threads: 0
Hi Friends
Actually I m working on a database project. I am using in this project D.A.O 3.6 Object Library. I added lots of forms absolutely for many purposes. Now the problem I faced is that for every form I have to write the following code.
Option Explicit
Dim db As Database
Dim rs As Recordset
Private Sub Form_Load()
Set db = OpenDatabase("C:\MyDatabase.mdb")
End Sub
I want to use one Module and set the above codes for all the forms.
I tried the following codes in Module but is showing "Error No 91"
Option Explicit
Dim db As Database
Public Function MyDataBase() As String
Set db = OpenDatabase("C:\MyDatabase.mdb")
End Function
Private Sub Command1_Click()
call MyDataBase
Set Tb = db.OpenRecordset("Select * From Table1")
End Sub
Please tell me any method that you think will solve my problem.
Regard,
Naveed
Actually I m working on a database project. I am using in this project D.A.O 3.6 Object Library. I added lots of forms absolutely for many purposes. Now the problem I faced is that for every form I have to write the following code.
Option Explicit
Dim db As Database
Dim rs As Recordset
Private Sub Form_Load()
Set db = OpenDatabase("C:\MyDatabase.mdb")
End Sub
I want to use one Module and set the above codes for all the forms.
I tried the following codes in Module but is showing "Error No 91"
Option Explicit
Dim db As Database
Public Function MyDataBase() As String
Set db = OpenDatabase("C:\MyDatabase.mdb")
End Function
Private Sub Command1_Click()
call MyDataBase
Set Tb = db.OpenRecordset("Select * From Table1")
End Sub
Please tell me any method that you think will solve my problem.
Regard,
Naveed
•
•
Join Date: Dec 2006
Posts: 4
Reputation:
Solved Threads: 1
•
•
•
•
Hi Friends
Actually I m working on a database project. I am using in this project D.A.O 3.6 Object Library. I added lots of forms absolutely for many purposes. Now the problem I faced is that for every form I have to write the following code.
Option Explicit
Dim db As Database
Dim rs As Recordset
Private Sub Form_Load()
Set db = OpenDatabase("C:\MyDatabase.mdb")
End Sub
I want to use one Module and set the above codes for all the forms.
I tried the following codes in Module but is showing "Error No 91"
Option Explicit
Dim db As Database
Public Function MyDataBase() As String
Set db = OpenDatabase("C:\MyDatabase.mdb")
End Function
Private Sub Command1_Click()
call MyDataBase
Set Tb = db.OpenRecordset("Select * From Table1")
End Sub
Please tell me any method that you think will solve my problem.
Regard,
Naveed
hi,
"Module"
Public db As dao.Database 'Declare variable for database connection
Public Sub connectdatabase()
Set db = DBEngine.OpenDatabase("C:\MyDatabase.mdb") 'Set the connection path
End Sub
"Form"
Dim rb As dao.Recordset 'Declare variable for recordset
Private Sub Command1_Click()
Call connectdatabase ' call the module
Set rb = db.OpenRecordset("table1") specidfy the table to open recordset
rb.AddNew
rb(0) = "1"
rb(1) = "Success"
rb.Update
End Sub
regards
Shailu
"Module"
Public db As dao.Database 'Declare variable for database connection
Public Sub connectdatabase()
Set db = DBEngine.OpenDatabase("C:\MyDatabase.mdb") 'Set the connection path
End Sub
"Form"
Dim rb As dao.Recordset 'Declare variable for recordset
Private Sub Command1_Click()
Call connectdatabase ' call the module
Set rb = db.OpenRecordset("table1") specidfy the table to open recordset
rb.AddNew
rb(0) = "1"
rb(1) = "Success"
rb.Update
End Sub
regards
Shailu
![]() |
Similar Threads
- how to read data from database page by page, please it is urgent... (JSP)
- Communicating with access database..Urgent<:) (Visual Basic 4 / 5 / 6)
- URGENT!: Saving Database information from ASP.NET Button (ASP.NET)
- plz help me to connect more than one table in the ms access database to the asp.net (ASP.NET)
- Simple ASP.Net Login Page (Using VB.Net) (ASP.NET)
- URGENT: UBBThreads MySQL database merge (MySQL)
- Importing SQL Script File - Urgent !! (Database Design)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Multicolumn combo box using win32 API
- Next Thread: Help me to read the files of Real Player (RM,RAM...etc)
| Thread Tools | Search this Thread |
Tag cloud for Visual Basic 4 / 5 / 6
* 6 429 2007 access activex add age append application basic beginner birth bmp calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver subroutine table tags textbox time timer urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows






