Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 21st, 2004, 08:49 AM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using Asp to Add/Delete Tables in a SQL database?

Here's one for you guys. Since I don't have access to sql server tools how can I delete or make new tables in our sql database? I use asp to update/add/modify the contents of each exsiting table, but I need to add some new ones and delete some old ones. I hope someone can help me out on this matter.

Thanks
__________________
-----------------------------------------------------------
\"Don\'t follow someone who\'s not going anywhere\" John Mason
 
Old April 21st, 2004, 09:58 PM
Registered User
 
Join Date: Apr 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

For Check Table Exsiting,Try.
<%
Private Function getTableName(xConn)
    Set xCommand = Server.CreateObject("ADODB.Connection")
    xCommand.Open xConn

    Set Rs = Server.CreateObject("ADODB.Recordset")
    Rs.ActiveConnection = xCommand
    Set Rs = xCommand.OpenSchema(20)
    While Not Rs.Eof
        If Rs.Fields(3).Value = "TABLE" Then
            getTableName = getTableName & Rs.Fields(2).Value & ","
        End If
        Rs.MoveNext
    WEnd

    Rs.Close
    Set Rs = Nothing
    xCommand.Close
    Set xCommand = Nothing
End Function
%>

<%
GetAllts = getTableName(xConnString)
Response.write "Tables List:" & GetAllts & "<BR/>"
If inStr(LCase(GetAllts),LCase("User_Table")) = 0 Then
    Response.write "Not Exsit."
Else
    Response.write "Exsiting."
End If
%>

Make new Table:

CREATE TABLE NewTableName (Field1 CHAR(5),Field2 VARCHAR(40))

Delete a Table:

DROP TABLE Table_Name
 
Old April 23rd, 2004, 07:59 AM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks lilo, but I get an error when I try to drop a table

<%
Drop Table ServiceIndex
%>

It says expected statement, and points to ServiceIndex

What am I missing??






Similar Threads
Thread Thread Starter Forum Replies Last Post
Add/Update/Delete Database records MANUALLY jn148 BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 December 14th, 2008 10:18 AM
how to EDIT,delete,add,items in my database zedekiah BOOK: Beginning ASP 3.0 2 May 15th, 2008 08:16 AM
Delete Data from a SQL Database using vb 2005 sahmed1983 VB Databases Basics 2 December 11th, 2006 03:16 PM
What are the tables in Database In sql 2000 shahbaz_sb SQL Server 2000 3 July 25th, 2005 09:41 PM
Add new record in SQL Server database bhatnagar_shaily Classic ASP Components 3 September 24th, 2003 01:16 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.