I am trying to connect to my database on localhost but for some reason, it throws an exception, and I can't find out why and where.
private void Initialize()
{
server = "localhost";
database = "dbname";
uid = "uname";
password = "pass";
string connectionString;
connectionString = "SERVER=" + server + ";" + "DATABASE=" +
database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";
connection = new SqlConnection(connectionString);
}
This is my initialize function; my problem is with:
private bool OpenConnection()
{
try
{
connection.Open();
return true;
}
...
When I debug the program, it stays on "connection.Open();" line for a while, then I see "Exception thrown: 'System.Data.SqlClient.SqlException' in System.Data.dll" on console. But it's not crashing, just skipping.