title: Dynamically creating database and data source in ColdFusion
body: <p>I'm trying to create a database and data source dynamically from the user input.</p>
  
  <p>I'm not sure is that possible or not to create a database using cfquery tag without using data source.</p>
  
  <p><strong><em>For Data source creation</em></strong></p>
  
  <pre><code>&lt;cfscript&gt;
      adminObj = createObject("component","cfide.adminapi.administrator");
      adminObj.login("admin password");  
      myObj = createObject("component","cfide.adminapi.datasource");
      myObj.setMSSQL(driver="MSSQLServer",
          name="datasourceName", host = "127.0.0.1", port = "1433",
          database = "database", username = "userName", password="password", login_timeout = "30",
          timeout = "20", interval = 7, buffer = "64000", blob_buffer = "64000", setStringParameterAsUnicode = "false",
          description = "", pooling = true, maxpooledstatements = 1000, enableMaxConnections = "true",
          maxConnections = "300", enable_clob = true, enable_blob = true, disable = false, storedProc = true,
          alter = false, grant = true, select = true, update = true, create = true, delete = true, drop = false,
          revoke = false
          );
  &lt;/cfscript&gt;
  </code></pre>
  
  <p>I've tried to create a data source using above code statically it creating Datasource successfully</p>
  
  <p><strong><em>For database creation</em></strong></p>
  
  <pre><code>&lt;cfquery name="createDB" result="res"&gt;
      create database #form.dbname#
  &lt;/cfquery&gt;
  </code></pre>
  
  <p>but not able to create a database using the above code. I got the error, my objective needs to create database then data source by using the user input string.
  <a href="https://i.stack.imgur.com/Kbu8m.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Kbu8m.png" alt="enter image description here"></a></p>
  
  <p><strong><em>Any advice or help is appreciable</em></strong><br>
  Thanks in Advance.</p>