I can't seem to connect to my local database. Everytime I run it, it gives me a pop up blank windows (blank command line windows).
What do I miss?
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
namespace dbtest1
{
class Program
{
static void Main(string[] args)
{
string myConnectionString = "Initial Catalog=myDB;Data Source=localhost;Integrated Security=SSPI;";
SqlConnection myConnection = new SqlConnection(myConnectionString);
string myInsertQuery = "INSERT INTO tts (min, max, average, lh, stdev, main_id) Values(5,5,5,'ASU',5,55)";
SqlCommand myCommand = new SqlCommand(myInsertQuery);
myCommand.Connection = myConnection;
myConnection.Open();
myCommand.ExecuteNonQuery();
myCommand.Connection.Close();
}
}
}
when I run debug it gives me error at myConnection.Open();
SqlException was unhandled: 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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)