I need to open .sql files from a folder using c# . i am using this code to open .sql files
string[] Files = Directory.GetFiles(Folder);
foreach (string File in Files)
{
System.Diagnostics.Process.Start(File);
}
this code is working fine but...
I want to open SSMS in a specific server connection through c#.
Explanation: I want my c# code to open SSMS in a specfic server connection so that user dose not have to connect to a server when SSMS opens.
Thanks
Use System.Diagnostics.Process to start ssms and send the parameters
Process.Start("ssms.exe", "-S (local)\\sqlexpress -E C:\\SQLQuery1.sql");
Usage: ssms.exe [-S server_name[\\instance_name]] [-d database] [-U user] [-P password] [-E] [file_name[, file_name]] [/?]
[-S The name of the SQL Server instance to which to connect]
[-d The name of the SQL Server database to which to connect]
[-E] Use Windows Authentication to login to SQL Server
[-U The name of the SQL Server login with which to connect]
[-P The password associated with the login]
[file_name[, file_name]] names of files to load
[-nosplash] Supress splash screen
[/?] Displays this usage information
https://msdn.microsoft.com/en-us/library/h6ak8zt5%28v=vs.110%29.aspx
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.