Showing posts with label access. Show all posts
Showing posts with label access. Show all posts

Monday, March 26, 2012

How to Fix the "Can't access Database because its Read Only" problem

The error comes up like this -

System.Data.SqlClient.SqlException .... because the database is read-only

( I'm putting this here so searches can find it easier)

I got this idea from a related thread, but they used a NETWORK user that is obsolete in 2007.

I found that you have to edit the actual file properties on the ASPNETDB.MDF and ASPNETDB.LDF files so that the ASPUSER has full access. i.e. on the file properties, security tab, hit the Add button and type in ASP.NET then return. Back at the security properties, click on the 'Full Control' checkbox at the top. That took care of it for me.


This was after checking the IIS control panel for the properties on the folder that contained my application and App_Data folders to be sure that the "Write" checkbox was already checked, it was

Of course this assumes that you have installed the express version of SQL from MicrosoftAre you using SQL Server server instance or user instances, I am a bit confused as you are talking about LDF files and the App-Data folder on the other hand.

Jens K. Suessmeyer.

http://www.sqlserver2005.de
|||

My project is a webservice that I created with Studio 2005, in the default configuration if you have a database, its put into an APP_DATA folder in your webservice folder.

Its in that folder where the ASPNETDB.MDF and LDF files are located and it is there where the permissions must be set in this case. As I am serving files from a virtual directory I setup in IIS, the permission apply to the actual file location on my computer. The same would be true, though, if the files were copied to the wwwroot/myWebService/APP_DATA folder on the actual default web site on my computer.

To directly answer your question, the MDF and LDF files are the actual database file and log file for the SQL Express database that I'm using for my application. When creating a SQL-using project in Studio 2005, the system will automagically make these for you within your project and you can then access them directly in your APP_DATA folder. So as to your question about server or user instances, I am not sure that it applies as this is a SQL Express install (the free one from microsoft); maybe that corrsponds to a user instance in your environment (?)

Perhaps someone else on this thread knows exactly what you're talking about

Monday, March 19, 2012

How to find particular login has access to which databases?

Is there a way to get the list of database to which a particular login name has access to and also how find what access that particular login has in each database?
Appreciate your comments and suggestionsGive sp_helplogins a try|||Thanks! for the reply.. I had figured that out.. sp_helplogin is helpful.

Monday, March 12, 2012

How to find out which databases a user have access to?

Hi, my first question, tried to use search first but couldn?t find what I need.

Hopefully someone has asuggestion.

I work for a ISV producing HR applications.

When user starts the applications the program shows all databases that the user have access to. This is done by select all names from master..sysdatabases and then trying to "USE dbname" to see if user have access,. Users doesn't have sa rights.

This procedure takes approximately 90 secs for a server with 500 databases and that has become a problem.

Does anyone know off a faster method, any suggestions?

/Regards Anders

If you use the sys.databases view you will only see the databases where you have access to, as the meta data is secured in SQL Server 2005. If you are using a version prior SQL Server 2005, you will have to go through all database getting the information from the appropiate tables.


Jens K. Suessmeyer.

http://www.sqlserver2005.de

How to find out the reason for error 17883?

Hello, ereryone

I use MSDE in my system, and sometimes the following error occurs in MSDE. After that, I can not even access MSDE with the osql command.

Can anyone give some advice as how to deal with this kind of error or how to find the real reason? I have checked MS homepage, but I can not get the details of it.

Error: 17883, Severity: 1, State: 0 The Scheduler 0 appears to be hung. SPID 0, ECID 0, UMS Context 0x003B70F8

Thanks in advance.

check this: http://support.microsoft.com/kb/319892/

How to find out row that was just inserted?

hi folks,
Is it possible to find out the row which was just inserted in a table? I am creating a trigger and i m trying to access the row which was just inserted into the table. Any suggestions? Thanks a million!
GayathriWithin a trigger you can access the newly inserted/updated/deleted fields by referencing virtual tables named:
"inserted" - holds new and updated records
"deleted" - holds deleted records

You just reference these tables as you would any permanent table:

select count(*)
from YOURTABLE
inner join INSERTED
on YOURTABLE.PRIMARYKEY = INSERTED.PRIMARYKEY

blindman|||My code is as follows

DECLARE job_number_cursor CURSOR FOR
SELECT JobNumber
FROM asiapac702_test.dbo.tblCustServiceHistoryHdr
where JobNumber = Inserted.JobNumber
OPEN job_number_cursor
FETCH NEXT FROM job_number_cursor INTO
@.job_number

CLOSE job_number_cursor
DEALLOCATE job_number_cursor

But i get an error saying
"The column prefix 'Inserted' does not match with a table name or alias name used in the query. "

Is there any other syntax that i am missing?|||try this...

DECLARE job_number_cursor CURSOR FOR
SELECT JobNumber
FROM asiapac702_test.dbo.tblCustServiceHistoryHdr
where JobNumber = (select Inserted.JobNumber from inserted)
OPEN job_number_cursor
FETCH NEXT FROM job_number_cursor INTO
@.job_number

CLOSE job_number_cursor
DEALLOCATE job_number_cursor|||Did modify to the code below but again it says "Invalid Object Name 'Inserted':(

Originally posted by rokslide
try this...

DECLARE job_number_cursor CURSOR FOR
SELECT JobNumber
FROM asiapac702_test.dbo.tblCustServiceHistoryHdr
where JobNumber = (select Inserted.JobNumber from inserted)
OPEN job_number_cursor
FETCH NEXT FROM job_number_cursor INTO
@.job_number

CLOSE job_number_cursor
DEALLOCATE job_number_cursor|||this is the suggestion from MS...

CREATE TRIGGER Trigger1 ON dbo.TableA
FOR INSERT
AS
DECLARE @.var1 INT
DECLARE @.VarA int

SELECT @.VarA = SELECT col2 FROM inserted
DECLARE cursor1 CURSOR FOR
SELECT col1
FROM TableB
WHERE col1 = @.VarA

OPEN cursor1
FETCH NEXT FROM cursor1 INTO @.var1

CLOSE cursor1
DEALLOCATE cursor1
GO|||So modifying it for your purposes...

DECLARE @.SearchJobNumber int
DECLARE @.job_number int
SELECT @.JobNumber = SELECT JobNumber from inserted

DECLARE job_number_cursor CURSOR FOR
SELECT JobNumber
FROM asiapac702_test.dbo.tblCustServiceHistoryHdr
where JobNumber = @.JobNumber
OPEN job_number_cursor
FETCH NEXT FROM job_number_cursor INTO
@.job_number

CLOSE job_number_cursor
DEALLOCATE job_number_cursor|||Here is how to rewrite your original statement to avoid the error you got:

DECLARE job_number_cursor CURSOR FOR SELECT JobNumber FROM Inserted
OPEN job_number_cursor
FETCH NEXT FROM job_number_cursor INTO
@.job_number

CLOSE job_number_cursor
DEALLOCATE job_number_cursor

The big question is why you are putting a cursor in a trigger. This is the database equivalent of pouring sewage into your gas tank.

blindman|||Cursor in trigger? Do not think it is good idea...|||I got the impression that things are getting on the wrong path. Summa summarum, the answer for your original question is given by Blindman in his first post:

select count(*)
from YOURTABLE
inner join INSERTED
on YOURTABLE.PRIMARYKEY = INSERTED.PRIMARYKEY

But this should be used in the trigger written on the table which you are interested in. Got the picture?
You probably get the error "Invalid Object Name 'Inserted'" because you are not using the code in the wright place.

Best regards!|||Can you not just use the @.@.IDENTITY property?

Or does this not work in a trigger?