Re: Connection issues between .Net framwok and SQl Express 2005
- From: RGF <Raf.Figueroa@xxxxxxxxx>
- Date: Mon, 19 Nov 2007 16:05:16 -0800 (PST)
On Nov 19, 3:42 pm, "Norman Yuan" <NoAddr...@xxxxxxxxxxxx> wrote:
Since you use SQL Server Express USER INSTANCE (hope you know what does that
mean. Unfortunately, ASP.NET management wizard create ASPNETDB automatically
as USER INSTANCE on existing SQL Server Express, assuming the developer
knows USER INSTANCE. The reality is most newbie have no idea on USER
INSTANCE at all and most ASP.NET book do not explain that), your call to the
"sqlcmd" (i do not know why you need to run that) only runs when the calling
process is under the same user account as the ASP.NET application, because
USER INSTANCE only allow single user access (not neccesarily single
connection, though), which is the user account used to run your ASP.NET
application, by default, it is ASPNET or Network Service, or any other
account you may have impersonated to.
If your application will be deployed to a host service provider's web
server, the host provider would most likely not support SQL Server Express
at all, so no USER INSTANCE will be available. If you know USER INSTANCE
well, and have no difficulty understanding how to change ASPNETDB to a full
SQL Server, that would be fine. If you don't, better spend some time on SQL
Server, and its Express USER INSTANCE. You'd discover there is most likely
no need to use USER INSTANCE for a web application/website.
"RGF" <Raf.Figue...@xxxxxxxxx> wrote in message
news:c3b107dc-5dee-464b-88d6-dedd6a1ac528@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Background:
I wrote a simple .bat file which executes the following sqlcmd call:
"sqlcmd -S BLUEBOX\SQLEXPRESS -d C:\App_Data\ASPNETDB.MDF -U
MyUserCount -P MyUserPassword -Q "Exec SendMessage" -o C:\Vocalico
\SendMailQuePump\Undelievered.txt"
the above command works fine, as long as no other application is
accessing the db.
Also, using VS2005 I wrote a simple web based calendar scheduling
application which I am testing by launching it via Visual Studio 2005
(using the built in ASP.Net Development Server), the web application
seems to work correctly as well.
The Problem Found:
When I run the VS2005 web application the sqlcmd fails to login (note
that the web application and the sqlcmd access the same db (C:\App_Data
\ASPNETDB.MDF)). The following is the error I get form SQL 2005
Express when running the sqlcmd while the web application is running:
Msg 5120, Level 16, State 101, Server BLUEBOX\SQLEXPRESS, Line 1
Unable to open the physical file "C:\App_Data\aspnetdb.mdf". Operating
system error 32: "32(The process cannot access the file because it is
being used by another process.)".
Msg 5120, Level 16, State 101, Server BLUEBOX\SQLEXPRESS, Line 1
Unable to open the physical file "C:\App_Data\aspnetdb_log.ldf".
Operating system error 32: "32(The process cannot access the file
because it is being used by another process.)".
File activation failure. The physical file name "C:\App_Data
\aspnetdb_log.ldf" may be incorrect.
Msg 4060, Level 11, State 1, Server BLUEBOX\SQLEXPRESS, Line 1
Cannot open database "C:\App_Data\ASPNETDB.MDF" requested by the
login. The login failed.
Msg 18456, Level 14, State 1, Server BLUEBOX\SQLEXPRESS, Line 1
Login failed for user 'MyUserCount'.
Questions:
Shouldn't SQL 2005 Express allow more than one user to connect and
authenticate to the db by default? Are there any settings I need to
modify in Visual Studio 2005 or SQL Express 2005 in order to allow my
web app and the sqlcmd command to co-exist and execute without
interfering with each other?
My Setup:
VS 2005
.Net Framework 2.0
XP Professional SP2
SQL 2005 Express
web.config connection string looks like this:
<add name="ASPNETDBConnectionString" connectionString="Data Source=.
\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated
Security=SSPI;User Instance=True" providerName="System.Data.SqlClient"/
I have been going around in circles on this issue, any help would be
greatly appreciated!
Sincerely,
-ralph
Norman,
If you've been working in the tech field long enough you should know
by now that as technology evolves you become a newbie again, yup I am
a newbie to the VS2005 and SQL 2005 Express beasts. I did not
encounter user instance issues in previous projects I did (older gen.
of MS technology).
You are correct in that, I used the helpful wizard, I mean, that is
what is there for.. and as far as I can remember, it did not give me
an option as to the USER INSTANCE option. Just to clarify, the
account used (impersonation) to run the ASP.Net page is different than
the account used by the sqlcmd call, I would presume that the separate
accounts would spawn their own access and process threads .. If I
understood your comment correctly "USER INSTANCE only allow single
user access" this would mean that only one account (or one user) would
be able to access and lock everyone out from a site that was created
using the connecting wizard in VS2005, right? that would strike me as
odd, but I will to some googling on "USER INSTANCE"...thanks for the
lead.
Also, with regards to the usage of sqlcmd. I resolved to use "sqlcmd"
because as you are probably are aware SQL 2005 Express does not come
with SSIS, and DTS (SQL 2000) refused to run against my instance of
SQL 2005 Express. So in order to schedule a SQL task to run
periodically, it is valid to batch out a sqlcmd call, it beats
executing the a store proc manually...:)
.
- Follow-Ups:
- Re: Connection issues between .Net framwok and SQl Express 2005
- From: Norman Yuan
- Re: Connection issues between .Net framwok and SQl Express 2005
- References:
- Prev by Date: Re: Unicode to HTML converter/cleaner
- Next by Date: Relative position text in FF...
- Previous by thread: Re: Connection issues between .Net framwok and SQl Express 2005
- Next by thread: Re: Connection issues between .Net framwok and SQl Express 2005
- Index(es):
Relevant Pages
|
|