Search
 
SCRIPT & CODE EXAMPLE
 

SQL

run sql script file and changes db name in this file using c#

public static void Main()    
{        
  string scriptDirectory = "c:	empsqltest";
  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);
        }
   }
}
Comment

PREVIOUS NEXT
Code Example
Sql :: open mysql port bitnami tomact 
Sql :: add colum in sql 
Sql :: mysql install windows 10 
Csharp :: raycast from camera to mouse unity 
Csharp :: minimize button c# 
Csharp :: unity mouse lock 
Csharp :: read text file to string c# 
Csharp :: get current computer name C# 
Csharp :: how to get a list of processes c# 
Csharp :: unity how to set gameobjkect enabled 
Csharp :: draw sphere gizmo unity 
Csharp :: how to edit postprocessing through script 
Csharp :: c# replace crlf 
Csharp :: get mouse position unity 
Csharp :: unity play particle system 
Csharp :: c# player movement 
Csharp :: c# AllowSynchronousIO to true 
Csharp :: asp.net core .gitignore 
Csharp :: how to make console wait c# 
Csharp :: writeline c# 
Csharp :: ping with c# 
Csharp :: c# string to double 
Csharp :: remove repeated items in a list unity 
Csharp :: c# randomize a list 
Csharp :: c# format decimal as currency 
Csharp :: radians to degree c# 
Csharp :: substring c# after character 
Csharp :: double to int c# 
Csharp :: unity c# set list to set active true 
Csharp :: c# string to char 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =