You need to add the part in bold (where *** is your password):
VB Code:
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source= c:\my documents\DB1.mdb[b];User Id=admin;Password=***;[/b]"
Printable View
You need to add the part in bold (where *** is your password):
VB Code:
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source= c:\my documents\DB1.mdb[b];User Id=admin;Password=***;[/b]"
Thanks for the reply Si, I think I may have the Database incorrectly saved.
When I try to open it in code using the connection string I get the error message
"Cannot start your application. The workgroup information file is missing or opened exculsively by another user."
Any ideas?
Is the database open in another program? (if so, close it)
If not, it is possible that the connection string is still not right, see the link in my signature for examples of variations.
Thanks, I used a connection string from the link, and it seems to connect no bother now (doesn't complain anyway).
I still have an issue though, code is briefly:-
Dim cnn1 As New ADODB.Connection
Dim rstDetails As New ADODB.Recordset
MyPath = App.Path
MyApp = "\MyDb.mdb;"
Connstring = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & MyPath & MyApp & "Jet OLEDB:Database Password=MyPass;"
cnn1.Open Connstring
rstDetails.Open "Mailing List", cnn1, , , adCmdTable
***This line throws up an error saying it can't find this.
strName = rstDetails.Fields("First Name")
***
I pasted the cnn1 connection info below in case it is of interest.
I am assuming the Database has been connected to at this point, though it would be nice to extract some info confirming this.
Provider=Microsoft.Jet.OLEDB.4.0;Password="";User ID=Admin;Data Source=C:\DEEWorkingFolder\Encryption\Encrypt2.mdb;Mode=Share Deny None;Extended Properties="";Jet OLEDB:System database="";Jet OLEDB:Registry Path="";Jet OLEDB:Database Password=MyPass;Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password="";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False
The database is connected, otherwise you would have got an error at the "cnn1.open" line.
The error about not being able to find "First Name" is due to that not being a field in your "Mailing List" table. Check you have the spelling correct, and that you are using the right table.
Like in adodc there is adodc1.refresh so whats in ado connection is it cn.refresh or any other thing ?
conn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & app.path & "/db1.mdb ;Persist Security Info=False;Jet OLEDB:Database Password=mikee_philQuote:
My database is password protected.
Where in the connection string is the password inserted please?
Can you please give an example of how to do this is i have been stuck on this for days. :thumb:Quote:
Originally Posted by mendhak
See How can I add a record to a database? from the DB FAQ.
You don't need to do anything other than open the recordset. You then simply use any code you want to work with/show the data.Quote:
Originally Posted by Muhammad Haris
I have used this tutorial and it has been great, but i was wondering how to Query another table
would i need to open a totaly new connection and have second connection to the database running ?
I have table1 which has a primary key ID this holds basilcy name and e-mail address i want to use this ID to link other tables.
I have table2 which i want to reference by the ID of the first table
So using this tutoral i have got the part working to display the info from table 1
now i also want to have it look up the ID in table2 and display any infomation it finds
I would assume the query could be somthing like
Select * from table2 where ID = "ID im looking up"
then basicly out put the data the same way as in table 1?
Im new at this sooo simple is good ;)
Any help on this would be apreciated
Welcome to VBForums! :wave:
You only need one connection - you can have multiple recordsets open thru it if you want.
Assuming that the data is "master-detail" (1 row in the first table relates to multiple entries in the second) then two recordsets is the way to go. Just declare another recordset object, and open it using the previous connection object.
If the data has a one-to-one relationship, you can use SQL to return both lots of data in the same recordset.
ok thanks i shall give it a go :)
Ok having a problem with searching, is there a like in built way to search the database, or am i going to have to dump it out to an array and loop the data to find a match ??
a code example would be helpful :)
You can check my recent post, I asked something like that !Quote:
Originally Posted by AllanM
http://www.vbforums.com/showthread.php?t=390117
I hope this will help you !
yes looks pritty good, thanks for the reply
This part of the code, where it fills the combo box with all the record numbers
rs.MoveFirst 'moves to the first record
Do Until rs.EOF = True 'this is the Loop to add items to the combo box
combo1.AddItem rs.Fields("field1") 'this adds items from field1 into the combo box
rs.MoveNext 'moves next record
Can you do rs.move to a specific record in the record set? so if they were all indexed via a number i could just jump stright to that record or would i have to say so somthing like rs.bof and then increment a loop of rs.MoveNext how ever many times i wanted to get to the correct record
i currenly have a search which will display a record number and from this would like to be able to just called up that record for editing
You can move to a specific record using the .Move method, however this is not the recommended approach - as data taken from databases should not care about the position of records (theoretically if you return the same set of data twice it may not be in the same order).
It is better to use something unique about the record instead, and load data based on that. If you have an Autonumber or Identity field, that is the perfect candidate for this, and can be used as part of an SQL statement to load (or edit) only that particular record.
hello
i need step by step instruction about connection strings for ADO..
i want to build database using vb6 and ms access..
my problem now i cant link vb6 to ms access.
The tutorial shows how to connect to an Access database, all you should need to change is the file name/location.
If you need further help, see the Connection Strings link in my signature.
I'm trying to open a database w/ a password, I can open it fine when there's no password, but what code do I use to add the password?
this is the mods I made to the code so far, but is says that "Could not find installable ISAM"
VB Code:
Set cn = New ADODB.Connection 'we've declared it as a ADODB connection lets set it. cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source= c:\DB1.mdb;Jet OLEDB;Database Password=mypassword" 'this is the connection string explained in the notes section. cn.Open
Thanx
p.s. code snippets help me, I'm a real noob, and a visual learner :wave:
also, is there a way to change the password on the .mbd file inside the program? The problem I actually have is that the messaging program I'm making uses a text file to store lots of user settings, the problem is is that an idiot in my class tries to screw it up constantly, so when I boot him off of it, he has already made a copy of the program storring the info, so he just replaces it back, and he's back on. I want a way to change the password without having to re-compile the program to change the password, to render his old copy uselesss
The error (almost always) means that the connection string is not correct.
Check out the "connection strings" link in my signature, and try the variations shown there. If that doesn't help, post a new thread instead of extending this one even further. ;)
Im using a password protected access 97 db. Why am I getting this error? :)
That same question was asked two posts earlier... read the post above yours for the answer. ;)
(the answer is also in post 41)
As this thread is getting so many repeated questions, I am closing the thread to new replies.
If anyone wants to ask a question relating to the tutorial, the chances are that it has already been answered here, so please read the previous replies.
If you cannot find an answer to your question, please create a new thread in the Database Development forum - several people who can help will read it.