Results 1 to 9 of 9

Thread: me going ado

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2002
    Posts
    6

    me going ado

    i have decided (finaly) 2 go with ado instead of dao (which i have been using 4 ages).. so could someone give me the easyest possible way 2 get and set a record in a database with ado??

    thnx

  2. #2
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    You would get more answers if you ask this question in "Database Development" forum but you can try an introductory tutorial for ADO by Beacon here:
    http://www.vbforums.com/showthread.php?threadid=153935
    Baaaaaaaaah

  3. #3
    joan_fl
    Guest
    Try something like this.. Its as easy as it was before with DAO.

    VB Code:
    1. Dim conn As New ADODB.Connection
    2. Dim sql As String
    3.  
    4. sql = "INSERT INTO TableName(ColumnName1, ColumnName2) VALUES(value1, value2)"
    5. conn.ConnectionString = "SomeDSNName"
    6. conn.Execute sql

    ADO is "almost" exactly like DAO... You should have no major progrems getting used to it.

    Check out some of there.. They should help.

    http://www.w3schools.com/ado/default.asp

  4. #4
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    Dim con as New ADODB.Connection
    Dim Rs as New ADODB.REcordset

    Con.Open ConString
    Rs.Open SQLString


    All done

    Ofcourse you have to make sure your ConString And SQLString Variables actually hold a valid Connection string and SQLQuery
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  5. #5
    joan_fl
    Guest
    Arc,

    Actually your going to need a bit more than that.

    Rs con, SQLString

    Rs needs to know what connection to use.

    Also you dont need to use a recordset object just to execute a SQL statement. I dont need to be soo picky though

  6. #6
    Junior Member
    Join Date
    Dec 2001
    Posts
    30
    Select reference Microsoft ADO 2.0 Library

    Dim con as Connection
    Dim rs as recordset

    Set con=new Connection
    Set rs=new Recordset
    With con
    .ConnectionString "User id=whatever is the user;pwd=what eve rpassword;data source=where the database is(machine name);Initial catalog=the name of the database
    .Provider="the provider name" For eg: for SQL SQLOLEDB
    .Open
    End With

    rs.open "the query statement",con

  7. #7
    PowerPoster Beacon's Avatar
    Join Date
    Jan 2001
    Location
    Pub Floor
    Posts
    3,188
    Nice work abdul!

    To the others the reason there's a tutorial is so you dont have to explain it all.

  8. #8
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    Originally posted by joan_fl
    Arc,

    Actually your going to need a bit more than that.

    Rs con, SQLString

    Rs needs to know what connection to use.

    Also you dont need to use a recordset object just to execute a SQL statement. I dont need to be soo picky though
    joan you are right about the con object having to be specified, I forgot to add that on, however you put it in the wrong place. It comes after the SQLString. Rs SQLString, con. You are also correct about not having to use the Recordset Object to execute an SQL Statement, that's just my preference.

    I Do have to ask you one question though. You Specified your connection String as a DSN. Do businesess really use DSN connections? I mean since it uses an ODBC driver instead of OLE DB i assumed it would not be used any more.
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  9. #9
    joan_fl
    Guest
    I Do have to ask you one question though. You Specified your connection String as a DSN. Do businesess really use DSN connections? I mean since it uses an ODBC driver instead of OLE DB i assumed it would not be used any more.
    DSNs are still used out there... there soo many older programs out there. Though your right.. I would think any new development would use a dsnLESS connection though with OLEDB.

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