Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > creating a database on the server

Reply
Thread Tools

creating a database on the server

 
 
Scott Baxter
Guest
Posts: n/a
 
      05-24-2004
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
%>



 
Reply With Quote
 
 
 
 
Curt_C [MVP]
Guest
Posts: n/a
 
      05-24-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
> %>
>
>
>



 
Reply With Quote
 
 
 
 
Scott Baxter
Guest
Posts: n/a
 
      05-24-2004
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:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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
> > %>
> >
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Database Database Database Database scott93727@gmail.com Computer Information 0 09-27-2012 02:43 AM
DataBase DataBase DataBase DataBase scott93727@gmail.com Computer Information 0 09-26-2012 09:40 AM
Creating a SQL Server Database Barry ASP .Net 2 05-02-2005 02:26 PM
Re-creating an SQL server database to another MSDE server NWx ASP .Net 3 03-04-2004 04:44 AM
Please help: Creating a table in a sql server database Paul ASP .Net 1 01-15-2004 05:43 PM



Advertisments