-1

What does

---------------------------

---------------------------
A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: SSL Provider, error: 0 - The wait operation timed out.)
---------------------------
OK   
---------------------------

that actually mean?

I take that to mean, "Things took too long so I just gave up."

I don't understand why there was a timeout though, because I set the timeout to 4 minutes and this error popped up in less than 30 seconds.

Why has this exact code been working the past week and now it just fails every single time???

I tried setting cmd.CommandTimeout = 240 which is a pretty long time to wait when debugging, and same problem. Nothing is getting updated in the database anymore. I don't understand what has changed.

    try
    {
        // Insert into database
        sqlconnection = new SqlConnection(@"Data Source=s1-removed-om;Initial Catalog=D-removed-t;Persist Security Info=True;User ID=D-removed-;Password=97-removed3-45;");

        sqlconnection.Open();

        cmd = new SqlCommand();
        cmd.Connection = sqlconnection;

        int count = 0;

        foreach (var item in files)
        {
            cmd.CommandText = @"insert into Images (Name, Credits) values ('" + item.Value + "', '" + credits + "')";
            cmd.ExecuteNonQuery();

            count++;
        }

        doneUpdatingDB = true;
    }
    catch (Exception exception)
    {
        MessageBox.Show(exception.Message);
        doneUpdatingDB = false;
    }
uSeRnAmEhAhAhAhAhA
  • 2,527
  • 6
  • 39
  • 64
  • You can look at: http://stackoverflow.com/questions/3270199/a-connection-was-successfully-established-with-the-server-but-then-an-error-occ – Jivan Apr 04 '14 at 04:24

2 Answers2

2

It's not a command timeout, you're experiencing a connection timeout here. It means that your client couldn't authenticate to the SQL Server in time (time being 30 sec by default). Increase the connection timeout. If this doesn't help, restart local machine. If this doesn't help, notify the server's administrator about the issue.

dean
  • 9,960
  • 2
  • 25
  • 26
  • Thanks dean. Could they have set the timeout to less than 30 seconds? I ask this because the error happens in less than 30 seconds. Usually about 20-25 seconds. – uSeRnAmEhAhAhAhAhA Apr 04 '14 at 04:59
  • 1
    It's a client setting: http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectiontimeout.aspx – dean Apr 04 '14 at 05:02
  • Sorry Dean, added `Connection Timeout=120` and it still won't work. – uSeRnAmEhAhAhAhAhA Apr 04 '14 at 05:40
  • Did you also restarted the local machine, and if that didn't help either, contacted the administrator? It's not a programming issue, you see. – dean Apr 04 '14 at 06:37
1

What framework are you using?

Try this:

1. Restart Visual Studio.
2. Re-build project. 
3. Re-install latest .NET Framework. 

Check this.

jomsk1e
  • 3,585
  • 7
  • 34
  • 59