Page 2 of 2 FirstFirst 12
Results 41 to 63 of 63

Thread: ADO Beginners Tutorial

  1. #41
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: ADO Beginners Tutorial

    You need to add the part in bold (where *** is your password):
    VB Code:
    1. cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    2.       "Data Source= c:\my documents\DB1.mdb[b];User Id=admin;Password=***;[/b]"

  2. #42
    Member
    Join Date
    Oct 2002
    Posts
    54

    Re: ADO Beginners Tutorial

    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?

  3. #43
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: ADO Beginners Tutorial

    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.

  4. #44
    Member
    Join Date
    Oct 2002
    Posts
    54

    Re: ADO Beginners Tutorial

    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 OLEDBatabase 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 OLEDBatabase Password=MyPass;Jet OLEDB:Engine Type=5;Jet OLEDBatabase 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 OLEDBon't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False

  5. #45
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: ADO Beginners Tutorial

    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.

  6. #46
    Lively Member
    Join Date
    Feb 2006
    Posts
    65

    Re: ADO Beginners Tutorial

    Like in adodc there is adodc1.refresh so whats in ado connection is it cn.refresh or any other thing ?

  7. #47
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    Philippines
    Posts
    468

    Re: Database Password Protection

    My database is password protected.

    Where in the connection string is the password inserted please?
    conn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & app.path & "/db1.mdb ;Persist Security Info=False;Jet OLEDBatabase Password=mikee_phil

  8. #48
    Lively Member
    Join Date
    Feb 2006
    Posts
    91

    Re: ADO Beginners Tutorial

    Quote Originally Posted by mendhak
    Store the values into variables.

    Then, use the connection object's EXECUTE method to execute the SQL INSERT query.
    Can you please give an example of how to do this is i have been stuck on this for days.

  9. #49
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: ADO Beginners Tutorial

    See How can I add a record to a database? from the DB FAQ.


    Quote Originally Posted by Muhammad Haris
    Like in adodc there is adodc1.refresh so whats in ado connection is it cn.refresh or any other thing ?
    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.

  10. #50
    Junior Member
    Join Date
    Feb 2006
    Posts
    20

    Re: ADO Beginners Tutorial

    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

  11. #51
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: ADO Beginners Tutorial

    Welcome to VBForums!

    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.

  12. #52
    Junior Member
    Join Date
    Feb 2006
    Posts
    20

    Re: ADO Beginners Tutorial

    ok thanks i shall give it a go

  13. #53
    Junior Member
    Join Date
    Feb 2006
    Posts
    20

    Re: ADO Beginners Tutorial

    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

  14. #54
    Hyperactive Member DubweiserTM's Avatar
    Join Date
    Dec 2005
    Location
    St-Ferdinand, Québec
    Posts
    427

    Re: ADO Beginners Tutorial

    Quote Originally Posted by AllanM
    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 !

    http://www.vbforums.com/showthread.php?t=390117

    I hope this will help you !

  15. #55
    Junior Member
    Join Date
    Feb 2006
    Posts
    20

    Re: ADO Beginners Tutorial

    yes looks pritty good, thanks for the reply

  16. #56
    Junior Member
    Join Date
    Feb 2006
    Posts
    20

    Re: ADO Beginners Tutorial

    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

  17. #57
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: ADO Beginners Tutorial

    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.

  18. #58
    Member
    Join Date
    Mar 2006
    Location
    Johor,Malaysia
    Posts
    45

    Re: ADO Beginners Tutorial

    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.

  19. #59
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: ADO Beginners Tutorial

    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.

  20. #60
    Fanatic Member ididntdoit's Avatar
    Join Date
    Apr 2006
    Location
    :uoıʇɐɔoן
    Posts
    765

    Exclamation Re: ADO Beginners Tutorial

    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:
    1. Set cn = New ADODB.Connection 'we've declared it as a ADODB connection lets set it.
    2.     cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    3.       "Data Source= c:\DB1.mdb;Jet OLEDB;Database Password=mypassword" 'this is the connection string explained in the notes section.
    4.     cn.Open

    Thanx

    p.s. code snippets help me, I'm a real noob, and a visual learner


    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
    Last edited by ididntdoit; Apr 28th, 2006 at 05:55 PM.

  21. #61
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: ADO Beginners Tutorial

    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.

  22. #62
    Hyperactive Member
    Join Date
    Aug 2004
    Posts
    344

    Re: ADO Beginners Tutorial

    Im using a password protected access 97 db. Why am I getting this error?
    Attached Images Attached Images  

  23. #63
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: ADO Beginners Tutorial

    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.

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width