creating a database on the server

Discussion in 'ASP .Net' started by Scott Baxter, May 24, 2004.

  1. Scott Baxter

    Scott Baxter Guest

    Is there a way to create a brand new database on the server?

    Someone gave me the asp code below, but I haven't gotten it to work yet.

    Thanks for any help.

    <%
    Dim strSQL
    Dim cnnTest

    strSQL = strSQL & "CREATE TABLE tblTest " & vbCrLf
    strSQL = strSQL & "(" & vbCrLf
    strSQL = strSQL & "ID int IDENTITY NOT NULL " & vbCrLf
    strSQL = strSQL & " constraint PK_tblTestID PRIMARY KEY, " & vbCrLf
    strSQL = strSQL & "FirstName varchar (30) NOT NULL, " & vbCrLf
    strSQL = strSQL & "LastName varchar (30) NOT NULL, " & vbCrLf
    strSQL = strSQL & "DateOfBirth datetime NULL" & vbCrLf
    strSQL = strSQL & ")" & vbCrLf

    Set cnnTest = Server.CreateObject("ADODB.Connection")
    response.write "got to here"
    cnnTest.Open "Provider=SQLOLEDB;Data Source=localhost;" _
    & "Initial Catalog=test;User Id=sa;Password=;" _
    & "Connect Timeout=15;Network Library=dbmssocn;"
    response.write "are we heare"
    cnnTest.Execute strSQL
    cnnTest.Close
    Set cnnTest = Nothing
    %>
     
    Scott Baxter, May 24, 2004
    #1
    1. Advertising

  2. Scott Baxter

    Curt_C [MVP] Guest

    that creates a Table, not a new DB....which is it you are after? Also, why
    are you posting it to these groups? some .Net, some not, some SQL.... ??

    --
    Curt Christianson
    Owner/Lead Developer, DF-Software
    Site: http://www.Darkfalz.com
    Blog: http://blog.Darkfalz.com


    "Scott Baxter" <> wrote in message
    news:...
    > Is there a way to create a brand new database on the server?
    >
    > Someone gave me the asp code below, but I haven't gotten it to work yet.
    >
    > Thanks for any help.
    >
    > <%
    > Dim strSQL
    > Dim cnnTest
    >
    > strSQL = strSQL & "CREATE TABLE tblTest " & vbCrLf
    > strSQL = strSQL & "(" & vbCrLf
    > strSQL = strSQL & "ID int IDENTITY NOT NULL " & vbCrLf
    > strSQL = strSQL & " constraint PK_tblTestID PRIMARY KEY, " & vbCrLf
    > strSQL = strSQL & "FirstName varchar (30) NOT NULL, " & vbCrLf
    > strSQL = strSQL & "LastName varchar (30) NOT NULL, " & vbCrLf
    > strSQL = strSQL & "DateOfBirth datetime NULL" & vbCrLf
    > strSQL = strSQL & ")" & vbCrLf
    >
    > Set cnnTest = Server.CreateObject("ADODB.Connection")
    > response.write "got to here"
    > cnnTest.Open "Provider=SQLOLEDB;Data Source=localhost;" _
    > & "Initial Catalog=test;User Id=sa;Password=;" _
    > & "Connect Timeout=15;Network Library=dbmssocn;"
    > response.write "are we heare"
    > cnnTest.Execute strSQL
    > cnnTest.Close
    > Set cnnTest = Nothing
    > %>
    >
    >
    >
     
    Curt_C [MVP], May 24, 2004
    #2
    1. Advertising

  3. Scott Baxter

    Scott Baxter Guest

    Hello,

    Thanks for your help. I just wanted to create the actual database on the
    server, then create a table within the database. I realize the sample code
    I sent is probably not the right code.

    I posted to several groups I thought seemed related to this question. Maybe
    I picked the wrong ones.

    Thanks.

    Scott Baxter

    "Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
    news:...
    > that creates a Table, not a new DB....which is it you are after? Also, why
    > are you posting it to these groups? some .Net, some not, some SQL.... ??
    >
    > --
    > Curt Christianson
    > Owner/Lead Developer, DF-Software
    > Site: http://www.Darkfalz.com
    > Blog: http://blog.Darkfalz.com
    >
    >
    > "Scott Baxter" <> wrote in message
    > news:...
    > > Is there a way to create a brand new database on the server?
    > >
    > > Someone gave me the asp code below, but I haven't gotten it to work yet.
    > >
    > > Thanks for any help.
    > >
    > > <%
    > > Dim strSQL
    > > Dim cnnTest
    > >
    > > strSQL = strSQL & "CREATE TABLE tblTest " & vbCrLf
    > > strSQL = strSQL & "(" & vbCrLf
    > > strSQL = strSQL & "ID int IDENTITY NOT NULL " & vbCrLf
    > > strSQL = strSQL & " constraint PK_tblTestID PRIMARY KEY, " & vbCrLf
    > > strSQL = strSQL & "FirstName varchar (30) NOT NULL, " & vbCrLf
    > > strSQL = strSQL & "LastName varchar (30) NOT NULL, " & vbCrLf
    > > strSQL = strSQL & "DateOfBirth datetime NULL" & vbCrLf
    > > strSQL = strSQL & ")" & vbCrLf
    > >
    > > Set cnnTest = Server.CreateObject("ADODB.Connection")
    > > response.write "got to here"
    > > cnnTest.Open "Provider=SQLOLEDB;Data Source=localhost;" _
    > > & "Initial Catalog=test;User Id=sa;Password=;" _
    > > & "Connect Timeout=15;Network Library=dbmssocn;"
    > > response.write "are we heare"
    > > cnnTest.Execute strSQL
    > > cnnTest.Close
    > > Set cnnTest = Nothing
    > > %>
    > >
    > >
    > >

    >
    >
     
    Scott Baxter, May 24, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paul
    Replies:
    1
    Views:
    365
    Miha Markic
    Jan 15, 2004
  2. NWx
    Replies:
    3
    Views:
    476
    Jodie Rapson
    Mar 4, 2004
  3. Barry

    Creating a SQL Server Database

    Barry, May 2, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    321
    Juan T. Llibre
    May 2, 2005
  4. Keith
    Replies:
    1
    Views:
    2,368
    Keith
    Jul 3, 2006
  5. =?Utf-8?B?U2V2ZW4=?=

    Creating new database 'Views' in Server Explorer

    =?Utf-8?B?U2V2ZW4=?=, Oct 29, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    334
    =?Utf-8?B?U2V2ZW4=?=
    Oct 29, 2006
Loading...

Share This Page