Friday, February 10, 2012

Connecting to Sql Server 2005 Express from three projects

Hi

I have set up a solution in Visual web developer 2005 express which is made up of three projects:

Website(this is the solution)
Admin (Sub directory of website)
members (Sub Directory of Website)

All three projects need to share the same database. However for devlopment purposes I only have Sql Server 2005 Express. Is this possible?

Any pointer would be great.

Thanks in advance

1. connectivity to a database can be done from any web page/any project
2. A database can hold many tables
3. Since it can have many tables, you can have any kind of and as much data you want there, even from different projects

The base answer is yes - there's no problem here - I guess we'd need a more exact question to get any further along.

|||

Besides using SQL Surface Area Configuration tool to configure SQL 2005 Express Edition with Advanced Services (SSEA) for allowing remote connections using TCP/IP only, I created an SQL user with password using SQL Management Studio Express in Security-Logins. This user was granted access to a specific database on the Server (a WinXP SP2 machine).Then I tried to connect to SSEA from another machine using OLEDB Provider for SQL Server, SQL Server authentication with above username and password, typed in the Database name, typed Server Name as\\MachineName\SQLExpress, but could not connect. What might have gone wrong? What more settings, if any need to be done on the Server end? I am not sure what roles need to be assigned to the SQL User, so I ticked all.

Mark Nongkhlaw

|||Is communucation at all possible between the two boxes? My point - might be a firewall stopping that traffic?|||

Hi

What I mean is if I have three projects, they will have three app_data folders. Now, so far I have only got Sql Server 2005 express to work when there is a mdb file in the app_data folder and it is attached to the sql server. Now if I have to do this for three separate projects I surely will not be able to share the same database between the three.

So the connection string I am currently using is

<addname="LocalSqlServer"connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|aspnetdb.mdf"providerName="System.Data.SqlClient"/>

Can you connect to a sql server 2005 express database in the old fashion way with out having to use theAttachDBFilename?

The database will be running on the same machine as the website so I guess it can be considered a local connection (I understand that there are difficulties with remote connections) .

I hope this makes more sense.

Cheers Steve

|||

Finally I understand your problem :)

Have you tried to specify a full path?

AttachDBFileName=c:\the-path-to-othersite-data-directory\aspnetdb.mdf

|||

And yes you can use SQLExpress as a "regular" database - that's what I do (never uses AttachFile) so connecting with for example

Server=SH-W2003CP\SQLEXPRESS;Database=kbmentor;Trusted_Connection=False;uid=sa;pwd=stefan;

is fine.

|||

Thanks,aspcode.net- The culprit WAS the WinXP firewall. I configured exceptions for SQL Server Express and SQL Browser and it now works.

Mark

|||Thanks guys, I too have now managed to get my site(s) to work.

No comments:

Post a Comment