Results 1 to 4 of 4

Thread: SQL security

  1. #1

    Thread Starter
    Fanatic Member SkiNLaB's Avatar
    Join Date
    Jan 2002
    Location
    Sydney, Australia
    Posts
    747

    SQL security

    Basically i have an option in my program where users can write their own sql, but i want to force it to allow only select queries

    so i just make sure the first word is select.

    is there anyway that someone can do an update, insert, or delete but having the first word as 'SELECT'

    ??

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    Yes, the Select...Into syntax can be used to create a new table, for example Select * Into EmployeeBackup From Employees.

    How do you execute your queries? Depending on the ADO provider, it is possible to execute multiple statements in one call, if you separate the statements with a semi-colon.

    for example the following (untested, based on what I read) code works using the SQLOLEDB provider.

    VB Code:
    1. Dim objDB As ADODB.Connection
    2.  
    3. Set objDB = New ADODB.Connection
    4.  
    5. objDB.Open "provider=sqloledb;data source=server1;initial catalog=northwind;integrated security =sspi"
    6.  
    7. objDB.Execute "Select * From Employees ; Delete * From Employees"
    8.  
    9. objDB.Close
    10. Set objDB = Nothing

    There are alternatives. You could create a better security model for your database. Create Views to the underlying tables. Users then select from the View instead.

  3. #3

    Thread Starter
    Fanatic Member SkiNLaB's Avatar
    Join Date
    Jan 2002
    Location
    Sydney, Australia
    Posts
    747
    Im using a mySQL database so views aren't a possibility. I am using ADO, i must test that double query thing, i suspect your right.

    As for select * into.

    is that a make - table query ? ie, that will make a new table not add into an existing one?

  4. #4
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    Yes, it is a make-table query.

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