1

I seem to have troubles to get my application (run from k) to connect to the database, this has occured after some changes i made to my SQLExpress instance and has probably something to do with the firewall.

The changes i made are as follows:

  1. I used to connect to the database using the sqlexpress instance name, i changed this to be able to use localhost, i went to sql server configuration, enabled TCP/IP and put the correct port in there, 1433. No problems here.

  2. I also created a new Login and user for my database, given it datareader and datawriter options.

The problem is i can connect to the database using localhost on sql server management studie, this works fine.

I can also connect using an internal tool, also using the localhost.

There is 2 problems i am not able to fix:

  1. The first problem lays in Visual studio, when i run my application there, i get unable to connect errors. I tried running without debugging and this solves the problem as windows asked me if i would allow my application to make changes blabla. Running with debugging doesnt ask me the same question but just throws me the error, hence i think this one is firewall related, when i disable my firewall completely it works.

  2. Im getting cannot open connection database errors, this ofcourse when i run without debugging to avoid previous problem, somehow my application cant seem to find the database when i try connecting via localhost, as said before, i can connect via localhost using sql management studio.

Any help would be appreciated, thanks in advance!

amaters
  • 2,266
  • 2
  • 24
  • 44
MBerkhof
  • 21
  • 5
  • 1
    Try running VS as an administrator. – John Saunders Jan 11 '13 at 09:57
  • Use wireshark and sniff your tcp/ip connection to see if this is a firewall issue. Just wondering, you connect to localhost using .\SQLEXPRESS ? then it connecto to localhost from local computer, so the NIC shouldn't access the firewall routing at all. – YvesR Jan 11 '13 at 10:19
  • 1
    When i disable the firewall i dont get the connection error as stated above. Im not using ".\SQLEXPRESS" i use "localhost" – MBerkhof Jan 11 '13 at 10:22

3 Answers3

1

Ive reinstalled the sqlserver this solved the issue. I can now work with localhost, though its not the solution i was looking for.

MBerkhof
  • 21
  • 5
0

Try to run visual studio as administrator.

Right click on VS icon and choose run as administrator.

Or take a look at this question: Point to localhost\sqlexpress using only localhost

Community
  • 1
  • 1
Mahmoud Fayez
  • 3,398
  • 2
  • 19
  • 36
  • I run visual studio as administrator by default, i also tried the right mouse button just to be sure, but didnt fix it, thanks for thinking with me though :) – MBerkhof Jan 11 '13 at 10:11
  • Already had sql configured to use localhost, it works when using microsoft sql server management studio, just not when using visual studio... – MBerkhof Jan 14 '13 at 12:16
  • There are OleDB Connection and SQL Connection – Mahmoud Fayez Jan 14 '13 at 18:48
0

Try to switch off UAC. Helped for me

amaters
  • 2,266
  • 2
  • 24
  • 44