Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx thread: CREATE SQL database dynamically


Message #1 by "Zach Clements" <clementz@c...> on Thu, 21 Mar 2002 19:31:19
Hi - I am pretty new to .NET and I want to be able to create a new SQL 
database using ASP.NET, and I want the database name to be what is entered 
using an input box.
Does anyone know how to do this?
Thanks - Zach
Message #2 by "Denis Gobo" <dgobo@w...> on Thu, 21 Mar 2002 14:32:36 -0500
Use CREATE DATABASE syntax
Append the db name to a string and pass the complete string to SQL
server
Same goes for tables


-----Original Message-----
From: Zach Clements [mailto:clementz@c...]
Sent: Thursday, March 21, 2002 2:31 PM
To: ASP+
Subject: [aspx] CREATE SQL database dynamically


Hi - I am pretty new to .NET and I want to be able to create a new SQL
database using ASP.NET, and I want the database name to be what is
entered
using an input box.
Does anyone know how to do this?
Thanks - Zach
Message #3 by "Zach Clements" <clementz@c...> on Thu, 21 Mar 2002 20:27:59
thanks for that but could you take a look at my code and see if I am doing 
something wrong? I will also attach the error.
-----------------------------
Compiler Error Message: BC30455: Argument not specified for 
parameter 'connection' of 'Public Overloads Sub New(cmdText As String, 
connection As System.Data.SqlClient.SqlConnection, transaction As 
System.Data.SqlClient.SqlTransaction)'.

Source Error:

 

Line 12: Dim myConnection as SQLConnection
Line 13: myConnection = new SQLConnection("server=localhost;uid=sa;pwd=;")
Line 14: CreateDbCommand = new SQLCommand("CREATE 
DATABASE "&DatabaseName&"", myConnection)
Line 15: end sub
Line 16: </script>
 

-----------------------------
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SQL" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Data.SqlCommand" %>
<script language="VB" runat="server">

sub Page_Load(Src as object, E as EventArgs )
  Dim DatabaseName as String
  Dim CreateDbCommand as SQLCommand 

	DatabaseName = Request.QueryString("NewDatabase")

  Dim myConnection as SQLConnection

	myConnection = new SQLConnection("server=localhost;uid=sa;pwd=;")
	CreateDbCommand = new SQLCommand("CREATE 
DATABASE "&DatabaseName&"", myConnection)

end sub
</script>
<html>
<body>
done
</body>
</html>
-------------------------

> Use CREATE DATABASE syntax
Append the db name to a string and pass the complete string to SQL
server
Same goes for tables


-----Original Message-----
From: Zach Clements [mailto:clementz@c...]
Sent: Thursday, March 21, 2002 2:31 PM
To: ASP+
Subject: [aspx] CREATE SQL database dynamically


Hi - I am pretty new to .NET and I want to be able to create a new SQL
database using ASP.NET, and I want the database name to be what is
entered
using an input box.
Does anyone know how to do this?
Thanks - Zach

  Return to Index