I am programming a Weatherstation which gets the data from an API. This works fine, but I want to store it in a database to draw a graph with it. But my code does not seem to work. I tried debugging it and it fails on the line where I want to open the database. It runs through the line where I create the DB.
These are the failing lines:
databaseCon = new SqlConnection(@"Data Source=
(LocalDB)\v10.0;AttachDbFilename=C:\Users\Jeroen
Laptop\Desktop\Eindopdrachten\WeatherStation\Eindopdracht\
Weather.mdf;Integrated Security=True;");
databaseCon.Open();
Error message in the console:
A first chance exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll
What happens:
I want to get the data from the API and put this into the DB for making a graph with temperatures, location and date. For this I created a database and I want to connect with it. This is where the error kicks in. I get the error from above. When I debug that message shows up a few times(100 or so) and continues to run, without filling the database.
I hope someone here can give me some more information or can see what I do wrong.
Update:
I got the following message when trying to acces the database
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll
Additional information: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.)
I use Visual Studio 2010 with SQL server 2008. 2012 is not supported by my programming laptop.
Data Source=(localdb)\v11.0;.....(v11.0instead ofv10.0)