I don't like to use osql.exe, isql.exe, although N earlier, use Osql.exe to query the SQL Server server in the LAN. ADO.NET is enough. As long as "Go" is filtered. As follows: use system; use system.data; using system.io; using system.collections; using system.data.sqlclient; Namespace ExecuteSqlfile {////
/// summary> public class dbaccess {public dbaccess () {} #region attribute private static string constr = ""; private static string constring {get {if (constr == ") {Try {xmldocument doc = new XmlDocument (); doc.Load ( "serverConfig.xml"); string userid = doc.SelectSingleNode ( "ServerConfig / UserId") InnerText;. string password = doc.SelectSingleNode ( "ServerConfig / passWord") InnerText;. string servername = doc.SelectSingleNode ( "ServerConfig / ServerName") InnerText;. string database = doc.SelectSingleNode ( "ServerConfig / DataBase") InnerText;. ConStr = "server =" servername "; uid =" userid "; pwd = " password "; database = " database;} catch (Exception ex) {throw ex;}} return ConStr;}} private static SqlConnection Con; public static SqlConnection MyConnection {get {if (Con == null) {Con = New SqlConnection (Constring);} Return Con; } #Endregion ///