Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: SQL Help  (Read 3481 times)

0 Members and 1 Guest are viewing this topic.

Gizmo73

    Topic Starter


    Intermediate

  • We do only what we are meant to do
    SQL Help
    « on: October 31, 2006, 09:48:43 PM »
    I'm trying to create an Access database using SQL. I'm very new at this language, in fact have never created a database through a script or SQL before. The error I'm getting says:

    Error Type:
    Microsoft VBScript compilation (0x800A0401)
    Expected end of statement
    /InternetProgrammingIIDocs/Practice/Chapter 22/Accounting.asp, line 10, column 16
    CREATE DATABASE Accounting
    -----------------^

    Here is my entire code below:

    <%@ Language=VBScript %>
    <html>
    <head>
    <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
    <title>Accounting</title>
    </head>
    <body>

    <%
          CREATE DATABASE Accounting
          ON
                (FILE = Accounting,
                 FILENAME = G:\Internet Programming II\Practice\Chapter 22\Accounting.mdb,
                 SIZE = 10,
                 MAXSIZE = 50,
                 FILEGROWTH = 5)
          LOG ON
                (FILE = AccountingLog
                 FILENAME = G:\Internet Programming II\Practice\Chapter 22\Accounting.ldb,
                 SIZE = 5MB,
                 MAXSIZE = 25MB,
                 FILEGROWTH = 5MB)
                
          GO
    %>

    </body>
    </html>

    According to every source I've viewed on the net, you simple create a database by using the words CREATE DATABASE , but my browser says it's wrong. Is there some kind of dll or something I'm suppose to include before using SQL statements? I feel something is being missed.

    Nick

    steelegbr

    • Guest
    Re: SQL Help
    « Reply #1 on: November 01, 2006, 05:03:17 AM »
    Creating a database via SQL. Hmm....

    You are doing it a very different way to how I do, but this is how I would do it

    Code: [Select]
    <%

    ' Initialise the variables

    dim dbConnection   ' Database connection
    dim strSQL             ' SQL Query

    ' Connect to the database

    set dbConnection = Server.CreateObject("ADODB.Connection")
    dbConnection.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("../database.mdb")

    ' Perform the SQL action

    strSQL = "SQL COMMAND GOES HERE"
    dbConnection.Execute strSQL

    ' Close the connection

    dbConnection.Close

    %>

    Information on SQL can be found at http://www.w3schools.com/sql
    « Last Edit: November 01, 2006, 05:06:24 AM by steelegbr »