I am having a problem connecting to the database. I started with a new blank solution, then added a WCF library project, and finally, last but not least, a WCF website (service). On the website, I added a link to the library where I have an interface (data contract), a class that implements the interface and dataclasses. I am trying to connect to a database on a server and try to get some data from there. Therefore, the connection string looks like this:
<add name="myConnectionString" connectionString="Data Source=MyServer; Initial Catalog=MyDatabase; User Id=me; Password=me123;" providerName="System.Data.SqlClient" />
and this is how I try to connect to the database:
public List<string> GetEngagements(string id) { string sql = "SELECT myColumn FROM myTable WHERE Id = '" + id + "'"; string connString = string.Empty; SqlConnection connDB; connString = ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString; connDB = new SqlConnection(connString); SqlCommand command = new SqlCommand(sql, connDB); connDB.Open(); SqlDataReader rdr = command.ExecuteReader(); List<string> numbers = new List<string>(); while (rdr.Read()) { numbers.Add(rdr[0].ToString()); } rdr.Close(); return numbers; }
I get an exception in connDB.Open (). Then the exception message says: SQL Server user instance could not be created due to a failure in starting the process for the user instance. The connection will be closed.
I get this message for 2 days, I searched a lot and deleted the directory C: \ Documents and Settings \ username \ Local Settings \ Application Data \ Microsoft \ Microsoft SQL Server \ SQLEXPRESS, but it does not work for me ..
Any solution ???? help me please
source share