473,412 Members | 3,015 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

deploy asp.net application with sql server express database

Hi there

I had no luck in getting the following question answered in the SQL Server
newsgroups. Please point me in the right direction.

Background: I am using the "System.Data.SqlClient" namespace and a
SqlConnection() object to connect to a local SQL Server 2005 Express
database from within VB code contained in <SCRIPT /> tags in an ASP.NET
page. I use Windows authentication (ie. "Integrated Security=SSPI;") to
connect to the database, and Windows then uses the (local)\ASPNET account to
make a connection.

Problem: Every week there is a new database to attach. Making use of the
XCopy functionality with AutoClose enabled, I simply delete the old .mdf
file, copy the new .mdf file to that directory, and then let the
"AttachDBFilename=..." part of the connection string attach the database.
The problem is, the database file I want to attach is created on a different
SQL Server, and as such does not contain login and permissions for the local
machine's ASPNET user account. At present I am manually adding the login
(exec sp_grantlogin '(local)\ASPNET') and user (exec sp_grantdbaccess
'(local)\ASPNET') each time I attach a new database. Surely there must be an
automatic way?! I can but I'd prefer not to give the ASPNET account login
and database access from the SQL Server that I use to create the databases,
since that would mean keeping track of the various user, machine and network
names, which would be a nightmare.

Please help!

Best regards
Loane


Nov 19 '05 #1
5 2335
if your aspnet account is a "system administrator" then this account should
access all databases.
"Loane Sharp" <lo************@hotmail.com> wrote in message
news:Ot**************@TK2MSFTNGP12.phx.gbl...
Hi there

I had no luck in getting the following question answered in the SQL Server
newsgroups. Please point me in the right direction.

Background: I am using the "System.Data.SqlClient" namespace and a
SqlConnection() object to connect to a local SQL Server 2005 Express
database from within VB code contained in <SCRIPT /> tags in an ASP.NET
page. I use Windows authentication (ie. "Integrated Security=SSPI;") to
connect to the database, and Windows then uses the (local)\ASPNET account
to
make a connection.

Problem: Every week there is a new database to attach. Making use of the
XCopy functionality with AutoClose enabled, I simply delete the old .mdf
file, copy the new .mdf file to that directory, and then let the
"AttachDBFilename=..." part of the connection string attach the database.
The problem is, the database file I want to attach is created on a
different
SQL Server, and as such does not contain login and permissions for the
local
machine's ASPNET user account. At present I am manually adding the login
(exec sp_grantlogin '(local)\ASPNET') and user (exec sp_grantdbaccess
'(local)\ASPNET') each time I attach a new database. Surely there must be
an
automatic way?! I can but I'd prefer not to give the ASPNET account login
and database access from the SQL Server that I use to create the
databases,
since that would mean keeping track of the various user, machine and
network
names, which would be a nightmare.

Please help!

Best regards
Loane

Nov 19 '05 #2
isn't that a bit dangerous?

if your aspnet account is a "system administrator" then this account
should access all databases.

Nov 19 '05 #3
yeap...
the only other solution is to restore the access to the user like you do it
"Loane Sharp" <lo************@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
isn't that a bit dangerous?

if your aspnet account is a "system administrator" then this account
should access all databases.


Nov 19 '05 #4
How about impersonation? If you are not familiar with it, the declaration
comes in the web.config file inside the <system.web> section and to
impersonate the connecting user, use
<identity impersonate="true"/>
or to impersonate a specific user, use
<identity impersonate="true" userName="domain\UserName"
password="whatever"/>
"Loane Sharp" <lo************@hotmail.com> wrote in message
news:Ot**************@TK2MSFTNGP12.phx.gbl...
Hi there

I had no luck in getting the following question answered in the SQL Server
newsgroups. Please point me in the right direction.

Background: I am using the "System.Data.SqlClient" namespace and a
SqlConnection() object to connect to a local SQL Server 2005 Express
database from within VB code contained in <SCRIPT /> tags in an ASP.NET
page. I use Windows authentication (ie. "Integrated Security=SSPI;") to
connect to the database, and Windows then uses the (local)\ASPNET account
to
make a connection.

Problem: Every week there is a new database to attach. Making use of the
XCopy functionality with AutoClose enabled, I simply delete the old .mdf
file, copy the new .mdf file to that directory, and then let the
"AttachDBFilename=..." part of the connection string attach the database.
The problem is, the database file I want to attach is created on a
different
SQL Server, and as such does not contain login and permissions for the
local
machine's ASPNET user account. At present I am manually adding the login
(exec sp_grantlogin '(local)\ASPNET') and user (exec sp_grantdbaccess
'(local)\ASPNET') each time I attach a new database. Surely there must be
an
automatic way?! I can but I'd prefer not to give the ASPNET account login
and database access from the SQL Server that I use to create the
databases,
since that would mean keeping track of the various user, machine and
network
names, which would be a nightmare.

Please help!

Best regards
Loane

Nov 19 '05 #5
thanks very much Chris, Jeje, all worked perfectly. Best regards Loane
Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Steve | last post by:
I have an asp.net 2.0 application which runs perfectly offline with a sql express database. However, when I ftp the files online, I keep receiving a permission error. The sql server express I...
1
by: webrod | last post by:
Hello everybody, I have done a program using csharp (windows form). It uses a SQL Express database. I have done the deployment phase. In the properties of the project, and in the PUBLISH tab,...
1
by: tomix | last post by:
Hi, I need to deploy INTRANET ASP.NET 2.0 application and i would like to ask ig the following can be done using windows installer: 1.Install sql server express(must i add it to the...
38
by: kavsak | last post by:
Hi. Not sure that this is the right place to ask but here goes. I have an application based on access97 and VB6 which I need to upgrade. It has to handle up to 20 concurrent users on a Win2k...
5
by: Mahernoz | last post by:
Hi Everyone! I have a problem here. I have used the latest asp.net membership & profiles functionality in my site. I have 2 roles admin and user. I also have a user named admin. Now, my...
2
by: =?Utf-8?B?dHZpbg==?= | last post by:
Hi, I'm developing small windows application for my customer by using Microsoft Visual Basic 2005 Express Edition(free version) and i create sql database in it. my question is: 1. what...
1
by: Bobby Edward | last post by:
Here's the situation.... 1. Local dev environment is VS2005 and VS2008 / using SQL Express databases for data 2. Hosting company ONLY supports MS SQL Server 2005 databases Here are the...
4
by: Kerrin Banner | last post by:
Hello Hopefully a really simple question. We have just finsihed a SQL 2005 database and vb.net app. We have been using SQL server 2005 Management Studio during design. We now want to copy the...
0
by: =?Utf-8?B?Q29ubnVsbA==?= | last post by:
I have developed a Windows Application which will use a SQL Express 2005 database backend. I have developed the program in vb.Net 2003, is there a way of including the dotNetFrameWork 2.0 and the...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.