Link to home
Start Free TrialLog in
Avatar of bbimis
bbimis

asked on

sql express on windows server 2008

can someone link me or give me detailed instructions on how to setup sql express to work with my asp.net page.
I wrote a simple database nothing fancy using the server explorer. its named database1.mdf

works fine on my local pc but I'm wanting to put it on the server to test.  I keep getting sql errors which I assume is related to the connection. it says it can't connect to the master as guest? I just don't know how to set it up so any help would be great. thanks!
Avatar of Miguel Oz
Miguel Oz
Flag of Australia image

Assuming that the site is properly setup in IIS, you need to check:
1. Is  SQL Express properly installed? (Same version as your PC or higher - make sure you can access it using SSMS as shown here)
2. Is your site authentication windows authentication?
Chances are you are just missing 1 or 2.
If you are connecting to the website anonymously then you could have connection issues even if your code is working fine in your PC, then you should use SQL Server Authentication or impersonation.  (e.g. Add
 
If more help needed please specify/post:
1. Web form or Asp.net mvc? Version?
2. .NET/VS version
3. Web config file  (Local and server if different)
4. connection string (if not in config)
5. The exact error wording
Avatar of bbimis
bbimis

ASKER

Sorry for delay just got home. Anyway I took and check with the sql server manager and was able to connect when I hit test connection.
it then showed the databases like master and so on
User generated image
I have a database in my visual studio project called database1.mdf
with a connection string in the webconfig file as follows:
<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <system.web>
    <compilation debug="true" strict="false" explicit="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
  </system.web>
  <connectionStrings>
    <add name="dbconn"
    connectionString="Data Source=.sqlexpress\v12.0;AttachDbFilename=|DataDirectory|\database1.mdf;Integrated Security=True"
    providerName="System.Data.SqlClient"
/>
  </connectionStrings>
</configuration>

Open in new window


when I have it as localdb it works just fine when running on my local system.
<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <system.web>
    <compilation debug="true" strict="false" explicit="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
  </system.web>
  <connectionStrings>
    <add name="dbconn"
    connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\database1.mdf;Integrated Security=True"
    providerName="System.Data.SqlClient"
/>
  </connectionStrings>
</configuration>

Open in new window

I go to sql manager and hit attach and select the database1.mdf and I get the following error:
User generated image
this is a asp.net web form.
.net 4.5


and thanks!
ASKER CERTIFIED SOLUTION
Avatar of Miguel Oz
Miguel Oz
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bbimis

ASKER

thanks sorry for delay getting back