// // Licensed to the Apache Software Foundation (ASF) under one or more // contributor license agreements. See the NOTICE file distributed with // this work for additional information regarding copyright ownership. // The ASF licenses this file to You under the Apache License, Version 2.0 // (the "License"); you may not use this file except in compliance with // the License. You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // .NET Service Configuration V2.0 for Design Considerations for Service-Oriented Applications based on Windows Communication Foundation. Created with Microsoft .NET Framework 3.5 and Microsoft Visual Studio. Copyright 2008, Microsoft Corporation. //====================================================================================================== //This file contains SQLHelper logic, largely derived/modified from the MSDN Data Access Block. It //has the methods that perform ALL ADO.NET operations. //====================================================================================================== using System; using System.Configuration; using System.Data; using System.Data.SqlClient; using System.Collections; namespace Trade.Utility { /// /// The SQLHelper class is intended to encapsulate high performance, /// scalable best practices for common uses of SqlClient. /// public abstract class SQLHelper { /// /// Prepares a SQL Server Connection String from the host IP address /// and the port /// Used by the Configuration Service to generate a connection to the DB /// using info in the DBConfig table /// /// host's IP address /// port /// public static string GenerateSqlServerConnectionString(string host, int port) { return string.Format("server={0}", host) + ";database=StockTraderDB" + ";user id=trade;password=yyy;"; //+ string.Format("port={0}", port); } public static string GetAssemblyNameFromDBName(string DBName) { if (DBName.Equals("MSSQL", StringComparison.InvariantCultureIgnoreCase)) return "Trade.DALSQLServer"; else if (DBName.Equals("MySQL", StringComparison.InvariantCultureIgnoreCase)) return "Trade.DALMySQL"; else throw new Exception("Database name, " + DBName + ", not supported"); } } }