setup project to create the database
-
I am in need to create a setup file for my web application. I can able to create seup file for web application alone but i want to include the installer for creating database (if the sql server is not exist it has to prompt). How do I create the database and then add a table using C# i have a sql script on my hand?
Thanks Warm Regards Prakash-B
-
I am in need to create a setup file for my web application. I can able to create seup file for web application alone but i want to include the installer for creating database (if the sql server is not exist it has to prompt). How do I create the database and then add a table using C# i have a sql script on my hand?
Thanks Warm Regards Prakash-B
-
I am in need to create a setup file for my web application. I can able to create seup file for web application alone but i want to include the installer for creating database (if the sql server is not exist it has to prompt). How do I create the database and then add a table using C# i have a sql script on my hand?
Thanks Warm Regards Prakash-B
PrakashBhaskar wrote:
I am in need to create a setup file for my web application. I can able to create seup file for web application alone but i want to include the installer for creating database (if the sql server is not exist it has to prompt). How do I create the database and then add a table using C# i have a sql script on my hand?
Use Regex to parse sql script line by line and use ExecuteNonQuery to execute that line. Knock out 't' from can't, You can if you think you can :cool:
-
PrakashBhaskar wrote:
I am in need to create a setup file for my web application. I can able to create seup file for web application alone but i want to include the installer for creating database (if the sql server is not exist it has to prompt). How do I create the database and then add a table using C# i have a sql script on my hand?
Use Regex to parse sql script line by line and use ExecuteNonQuery to execute that line. Knock out 't' from can't, You can if you think you can :cool:
can you send me the code coz i am new to this deployment project plz.
Thanks Warm Regards Prakash-B
-
can you send me the code coz i am new to this deployment project plz.
Thanks Warm Regards Prakash-B
private static void CreateDBAndTables(SqlConnection sqlCon)
{
string[] SqlLine;
Regex regex = new Regex("^GO", RegexOptions.IgnoreCase | RegexOptions.Multiline);string txtSQL = GetScript("createDB.sql"); SqlLine = regex.Split(txtSQL); ExecuteSql(sqlCon, SqlLine);
}
private static void ExecuteSql(SqlConnection sqlCon, string[] SqlLine)
{
SqlCommand cmd = sqlCon.CreateCommand();
cmd.Connection = sqlCon;foreach(string line in SqlLine) { if(line.Length>0) { cmd.CommandText = line; cmd.CommandType = CommandType.Text; try { cmd.ExecuteNonQuery(); } catch(SqlException) { break; } } } }
Knock out 't' from can't, You can if you think you can :cool:
-
private static void CreateDBAndTables(SqlConnection sqlCon)
{
string[] SqlLine;
Regex regex = new Regex("^GO", RegexOptions.IgnoreCase | RegexOptions.Multiline);string txtSQL = GetScript("createDB.sql"); SqlLine = regex.Split(txtSQL); ExecuteSql(sqlCon, SqlLine);
}
private static void ExecuteSql(SqlConnection sqlCon, string[] SqlLine)
{
SqlCommand cmd = sqlCon.CreateCommand();
cmd.Connection = sqlCon;foreach(string line in SqlLine) { if(line.Length>0) { cmd.CommandText = line; cmd.CommandType = CommandType.Text; try { cmd.ExecuteNonQuery(); } catch(SqlException) { break; } } } }
Knock out 't' from can't, You can if you think you can :cool:
can you plz send me step by step process to creating this setup file. I want user has to input the database server server name (select from dropdown box), user name and password thru installation shield.
Thanks Warm Regards Prakash-B