Results 1 to 5 of 5

Thread: Run SQL

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 1999
    Posts
    46

    Post

    Hello, i start to write module to use like a DB Engine. I create all kind of functions and all use the database object of "Micorosft ADO 3.51".
    So i create a database object (DB As DataBase) and then i open it with OpenDataBase() function.

    ----The Problem-----
    Now i want to run SQL statments like INSERT INTO, DELETE, UPDATE and all other SQL but i don't now how to do it with the database object.

    Please help me out.
    Kiron

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    Code:
                    Dim SQL As String
                    SQL = "DELETE FROM SavedSystems WHERE SystemName = " & "'" & sSysName & "'"
                    DB.Execute SQL, dbFailOnError

    ------------------
    Marty

  3. #3
    Member
    Join Date
    Oct 1999
    Location
    Snellville, GA, USA
    Posts
    38

    Post

    In a message you said:
    Hello, i start to write module to use like a DB Engine. I create all kind of functions and all use the database object of "Micorosft ADO 3.51".
    So i create a database object (DB As DataBase) and then i open it with OpenDataBase() function.
    ----The Problem-----
    Now i want to run SQL statments like INSERT INTO, DELETE, UPDATE and all other SQL but i don't now how to do it with the database object.

    Please help me out.
    Kiron

    *********************************************
    I recommend you study up on your ADO code. First off, you should become familiar with the 3 objects of ADO: 1. The Connection Object, 2. The Command Object, 3. The Recordset object. Each is powerful in a unique way. I use the connection & recordset object the most. Also important is to know about connection strings, especially if you are ever planning to design 2 tier or n-tier server applications. ie the most basic would be the client-server application ( ie VB front end with a Access/SQL/Oracle back end ) Here is an example:
    (this is easier if you have a reference to Microsoft ActiveX Data Objects 2.1 Library in your project ( ADO VB6.0) To do this, click on project, then references, then look for Microsoft ActiveX Data Objects 2.1 Library.
    code example
    dim cn as adodb.connection
    dim rst as adodb.recordset
    set cn = new adodb.connection
    set rst = new adodb.recordset
    cn.open strConnectionString ( There are many ways this string can be gotten easily. Email me for further details. )
    with rst
    'locktype & cursorlocation I am not so familiar with, but referr to help in VB for proper settings
    .LockType = adLockBatchOptimistic
    .CursorLocation = adUseServer
    .open "Put your SQL statement here"
    end with
    You might ask why go through all that? Well, if you might operate over a different database backend than you did your prototype with, then all you would have to do is change your connection string and make sure your SQL statements are using the correct syntax for the new backend database, and you are cooking without any additional code changes. Good luck.
    -Elias

  4. #4
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    ELIAS

    I hate to tell you that you wasted all of your time writing that beautiful reply, but I'm afraid that Kiron wanted to know about DAO, not ADO. It looks like he transposed the letters. OOPS! I can tell because ADO does not have a DBEngine object, or a OpenDatabase method, or a Database object. DAO has all of these.

    Sorry man!

  5. #5

    Thread Starter
    Member
    Join Date
    Nov 1999
    Posts
    46

    Post

    Hello, first thank you all for the answers thank you very much.
    now I do mean about DAO because I gona write a program that use only one database and this database is in the same computer as the program will be so that's way i didn't use any connections and stuff.
    The second this is i didn't use the DBEngine of Microsoft, i write something like the [DoCmd] object of Access that know to run SQL, open RecordSet and more. I can send to you the module when i done.

    and again thank you for the answers.

    Bye~

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