Click here to Skip to main content
15,901,035 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Please any one give ideas and solutions for database server creation tools

What I have tried:

DataTable table = SmoApplication.EnumAvailableSqlServers(true);
            string ServerName = Environment.MachineName;
            foreach (DataRow row in table.Rows)
            {
                Console.WriteLine(row["Name"].ToString());
            }
            dataGridView1.DataSource = table;


This only displaying server name we need to create new server and instance name
Posted
Updated 7-Feb-20 6:25am

Is that what you are after?
SQL Server installation - Command Prompt parameters - SQL Server | Microsoft Docs[^]
To install the engine / create an instance you need to use a proper installer.

Once done, you can programmatically create a database and its tables, since this only requires you to issue sql commands on previously created instance.
 
Share this answer
 
A database server is a big, complicated object - and for good reason, it's got a big, complicated job to do!

You don't "create database server and instance name programatically", you install a database server system on an appropriate PC somewhere in your network and give it a name: and even that is fraught with problems and a complicated job that needs careful planning before you start.

And in general, your app shouldn't even be thinking about performing server installation itself, although it can be done:

0) You can only distribute SQL Server Express for copyright reasons - not SQL Server full version.
1) They may already have SQL Server installed on the network. If so, then they will presumably want to use that version.
2) If they do have SQL server installed and you start proliferating SQL server Express instances, you are going to annoy the heck out of the database administrator...
3) A single site installation of SQL Server is a lot more likely to be backed up than a number of scattered version under user control.
4) Sql server is quite complex for a "normal" user to install and administer - it is not a good idea!
5) It will destroy the primary advantage of using Sql Server over SqlCE or SQLite - multiuser access. If everyone installs their own copy of SQL server, then you will have multiple copies of your database, each used by a single person. This will cause some confusion, and (depending on how you wrote the original database) may take some considerable effort to combine into a single instance when the problem is realized.

Have a good think about what you are trying to achieve: I suspect you are going down totally the wrong rabbit hole!
 
Share this answer
 
In addition to what has been said about creating an instance, here is a way to do it with the free Inno Setup installer: Inno Setup Script to Install SQL Server 2008 R2 with Tools[^]

Also take a look at Inno Setup Dependency Installer:
GitHub - domgho/innodependencyinstaller: Modular InnoSetup Dependency Installer[^]
This allows to install all kind of pre-requisites, like SQL Server Express, using a web installer, so your installer can remain compact in size.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900