"run sql script file and changes db name in this file using c#" Code Answer's
You're definitely familiar with the best coding language SQL that developers use to develop their projects and they get all their queries like "run sql script file and changes db name in this file using c#" answered properly. Developers are finding an appropriate answer about run sql script file and changes db name in this file using c# related to the SQL coding language. By visiting this online portal developers get answers concerning SQL codes question like run sql script file and changes db name in this file using c#. Enter your desired code related query in the search bar and get every piece of information about SQL code related question on run sql script file and changes db name in this file using c#.
run sql script file and changes db name in this file using c#
public static void Main()
{
string scriptDirectory = "c:\\temp\\sqltest\\";
string sqlConnectionString = "Integrated Security=SSPI;" +
"Persist Security Info=True;Initial Catalog=Northwind;Data Source=(local)";
DirectoryInfo di = new DirectoryInfo(scriptDirectory);
FileInfo[] rgFiles = di.GetFiles("*.sql");
foreach (FileInfo fi in rgFiles)
{
FileInfo fileInfo = new FileInfo(fi.FullName);
string script = fileInfo.OpenText().ReadToEnd();
using (SqlConnection connection = new SqlConnection(sqlConnectionString))
{
Server server = new Server(new ServerConnection(connection));
server.ConnectionContext.ExecuteNonQuery(script);
}
}
}
Source: stackoverflow.com
All those coders who are working on the SQL based application and are stuck on run sql script file and changes db name in this file using c# can get a collection of related answers to their query. Programmers need to enter their query on run sql script file and changes db name in this file using c# related to SQL code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about run sql script file and changes db name in this file using c# for the programmers working on SQL code while coding their module. Coders are also allowed to rectify already present answers of run sql script file and changes db name in this file using c# while working on the SQL language code. Developers can add up suggestions if they deem fit any other answer relating to "run sql script file and changes db name in this file using c#". Visit this developer's friendly online web community, CodeProZone, and get your queries like run sql script file and changes db name in this file using c# resolved professionally and stay updated to the latest SQL updates.