|
-
July 20th, 2002, 11:04 PM
#1
Dao
How can I use DAO code to open a database with a password, as well as setting it's recordset?
I don't wanna create a Data Control whenever I wanna do something like that.
Please help.
Thanks.
Woobi
-
July 21st, 2002, 01:21 AM
#2
Try to use the .openrecordset()
e.g.
Dim QdfSir As QueryDef
Dim RecoMSir As Recordset
'gstrConn is the connect string
With QdfSir
.Connect = gstrConn
.SQL = "Select A.*,B.Sir_Gen_Date From Sir_Items A,Sir B where a.Sir_Code+a.Fin_Suffix=B.Sir_Code+B.Fin_Suffix and B.Sir_Code>='" & TxtFSirNo.Text & "' And B.Sir_Code <= '" & TxtTSirNo.Text & "' And B.Fin_Suffix = '" & TxtFSuffix.Text & "'" & StrSql
Set RecoMSir = .OpenRecordset()
-
July 21st, 2002, 01:33 AM
#3
So what do I put as the connect string?
-
July 21st, 2002, 03:56 PM
#4
Something like this
gstrConn = "odbc;dsn=" & Trim(gstrDsn) & ";uid=" & Trim(gstrUser) & ";pwd=" & strpw & ";database=" & gstrDb & ";"
-
July 23rd, 2002, 05:08 AM
#5
Does that mean whenever I try to create a new querydef, I have to reconnect to the database all the time? But what if it's a single user database? That wouldn't cause the program to go haywire?
I thought the database can only be opened once and during the program?
-
July 23rd, 2002, 08:08 AM
#6
Using DAO to get into an Access database?
Set reference in project to MS DAO 3.6 Object Library.
------------------------------------------------------------------
Dim DB1 as DAO.database
Dim RS1 as DAO.Recordset
Dim ssql as string
Dim pathstringvariable as string
Dim passwordstringvariable as string
pathstringvariable = "C:\MyProjectFolder\SuperDatabase.mdb"
passwordstringvariable="Theshadowknows"
Set DB1 = DAO.opendatabase(Pathstringvariable, false, false, ";pwd=" & passwordstringvariable)
ssql = "SELECT * FROM Table1"
set rs1 = db1.openrecordset(ssql,dbopensnapshot)
------------------------------------------------------------------
Like that.
Hope That helps.
-Jpicasso
P.S. Stay as far away from data controls as possible.
-
July 23rd, 2002, 08:53 PM
#7
Thanks JPicasso_00, that is exactly what i was looking for. Thanks. =)
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
|