SQLEXPRESS Database Ownership, Sa, And Authentication Troubles
Dec 25, 2005
I installed VS2005 on my laptop at the office and of course, got the default instance of SQLEXPRESS. When I take my laptop home and log in (I use my NETWORKlogin login everywhere), I can't authenticate to use the database -- it doesn't like my login unless I'm physically at my office.
So, thinking I'm clever, I changed my SQLEXPRESS instance to use 'SQL Server and Windows Authentication mode' and tried to use the 'sa' login in my connection string. Login failed for 'sa' and since I had never set a password (yes, I tried using a blank) I executed the following query on my db:
The query works (?) but it my connection string doesn't and I'm still unable to use the management tool when not on the original network.
So, I thought I'd add a new, super secret special user, but alas, that has completely escaped me. That frightens me a bit because I'd really like to be able to deploy my database to my web host and trust the my connection strings will work.
So, here are my questions:
1. Can I set up my instance so that I don't have to be on the network on which I installed it in order for it to recognize me (since it's self contained on my machine)? If so, how?
2. How do I create new SQL users?
3. Has the connection string changed significantly, and consequently, am I missing something fundamental in my attempts to connect? If someone could toss out a working SQL Server Express 2005 connection string that doesn't use Windows authentication, that would be really appreciated.
Here's some info from my box, if it helps.
Microsoft SQL Server Management Studio Express 9.00.1399.00
Microsoft Data Access Components (MDAC) 2000.085.1117.00 (xpsp_sp2_rtm.040803-2158)
Microsoft MSXML 2.6 3.0 4.0 5.0 6.0
Microsoft Internet Explorer 6.0.2900.2180
Microsoft .NET Framework 2.0.50727.42
Operating System 5.1.2600
This what happened in Vista. I just set up my SqlServer Express (SSMS), attached my databases: all of them except one.
The reason why it happened is that when I copied my folder with DBs from XP to Vista I found out that one mdf file was missing.There was the log file for that DB intact. It is a somewhat secondar database (at leas temporary until I will have resolved some tricky issues in C# app, then it will get full load). When I bagan chenging my conn strings in C# to accomodate new Vista's tastes I realized that that DB was not attached to VS 2005 either. I began to investigate.
I went to XP and checked thoroughly. First I thought this DB (mdf file for this DB) was stored in another partition. It does not seem to be the case. The entire disk was searched: nothing found.
The weird thing is: I can see this DB in SSMS in XP with ALL tables intact. I opened the design and also opened the tables. The values are all there. This is my first question: how can it be explained? Could it be that all the tables are in the log file for this DB?
So at this point I have no way to copy the DB from XP to Vista the way I did before with other DBs.
The next problem is this:
I went to Vista and tried to restore this DB from a backup. The backup may not be too fresh but I do not care. All I need is the structures and stored procedures. Vista gives me hard time.
This is my code:
RESTORE DATABASE [intraDay] FROM DISK = 'J:SqlServerBackUpsIntraDayintraDayFullRM.BAK' WITH RECOVERY,
TO 'C:intraDay.mdf'; -- this is just to try the RESTORE in principle. I will restore the DB to a different folder.
GO
I get an error that
Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'TO'.
I understand that the MOVE clause may be missing. I tried that but got in trouble with it as well.
I recently installed Web Developer Express and SQLExpress and cannot get connected to the SQL to create the aspnetdb.mdf database file. I ran the utility aspnet_regsql.exe with the switches -E -A m but got a message stating that it could not connect because remote access might be disabled. I enabled remote access using both TCP/IP and pipes even though only local access is required. It still returns the same error message. The machine.config and web.config files have the correct entries for ConnectionStrings and Providers to specify SQLProviderMembership.
My system was crashing so I reinstalled everything. including SQL 2005 Express with management studio. I renamed the computer from the previous install. but for some reason the sql 2005 express management studio remembers the old machine name even when I create a new DB inside the management studio with the new computer name.when I try to change the ownership in properties-files it cant find the 'new computer nameuser'i double checked the computer name its correct. The funny thing is i installed express with the 'new computerame' anyone have a clue that may help with this what file needs to be edited?Thanks inadvance for any help.
I saw this option in SSMS under "Servers, Property, Security tab". I looked at BOL but I still don't understand what it is or what it is used. Any help appreciated.
i have a database with cross database ownership chaining enabled. data base was detached and reatached as a result owner changed from sa to account that was used during reataching. will this affect chaining?
I have a database called sky and its tables, views, procs and functions owned by sky. I need to replicate the sky database to another server. I had problem because those objects have ownership sky not dbo. I can not change ownership when replicate the database. How do I replicate database objects that are not owned by dbo? Is this possible or I have to change ownership from sky to dbo before replicate the database?
Thank you very much for your input and suggestions.
we have a group of developers which have created and asked us (DBAs) tocreate many objects in the databases including tables / storedprocedures / functions / etc.since our company is growing, however we have an increasing amount ofobjects that have either been abandoned or have several versions.in an effort to clean of the huge amount of clutter and anytime thatsomething simple like a stored proc needs to change, it is almostimpossible to predict exactly where we will see negative effects ofthis change.i am looking for a system (preferably without developing our own tool)that would keep track of history of database objects (in terms of whocreated it and what purpose it has) as well as link that to all thedevelopers/users we might need to notify of any changes to that object.Also, this should be linked to the application which rely on theobject.bottom line... every object in the database needs to have at least 1corresponding contact as well as the applications which us it.with this information, we can much more easily maintain objects in ourDBs.thx
We are having a problem with cross database ownership chaining. Below is a description of the problem:
I have a domain group named DOM1GROUP1 I have a domain user DOM2USER1 who is a member of DOM1GROUP1 (note that they are in different domains) I have a database DB1 which contains a stored procedure (st_insertdata) that does an insert in a table (tb_data) on DB2 DOM1GROUP1 has been granted login rights on the SQL Server DOM1GROUP1 is a user in both DB1 and DB2 DOM1GROUP1 has execute rights on procedure st_insertdata and insert rights on table tb_data. All objects are owned by the dbo schema. The database owner for DB1 and DB2 is sa
When DOM1USER1 executes st_insertdata an error is returned: The server principal "DOM1USER1" is not able to access the database "DB2" under the current security context.
I've played around with the options "trustworthy" and "db chaining" but these do not make any difference. The only thing that fixes this problem is if I create a login for DOM2USER1 and grant it access to DB2 (with no other rights other than membership of the public role).
It seems that SQL Server does not recognize that DOM2USER1 is a user in DB2 by virtue of its membership of the domain group DOM1GROUP1. Is there a way to get this to work without granting explicit rights to DOM2USER1?
i have enable cross database chain,but it return error message:
The server principal "S-1-9-3-1149532189-1170944071-2610337685-3868961652." is not able to access the database "db2" under the current security context.
I list the sql script as follows:
Code Block
use master; go create database db1; create database db2; go use db2 go create table table1 ( col int ) go use db1 go
create user u1 without login go create proc p1 as insert into db2.dbo.table1 values(1) go grant execute on p1 to u1
The SQL ERRORLOG shows: Error is 3414, Severity 21, State 2 and says: "An error occurred during recovery, preventing the database 'model' (database ID 3) from restarting." Just prior to this, I get a warning: "did not see LP_CKPT_END".
Any thoughts why this might be and how I can fix this?
I have created an installation application which will install the application with SQL Express and .NET Framework 2.0.
If i install this application in a Fresh system(i.e which is not having SQL Express), it is installing the application with new database instance successfully.
But if i try to install the same in a system which is already having SQL Express, throwing "Object reference exception" because it is not able to create the new database instance.
Hi, I have a web site in asp.net 2003 with sql 2000. Can I run this database with sqlExpress 2005. And what changes would be made in web.config file. This is due to I am going to check it with Window vista. Thanks in advance
I have install SQLExpress, too I download AdventureDB, but it created files *.mdf and *.ldf.Now in SQLExpress I cann't attach database witch mouse, I believe that it in code, how I can goal it?. Is there some other way to make this in SQLExpress?
I created a sqlexpress database in visual studio 2005 and can't figure out to move the database to my hosting company( godaddy ). I can't connect remotely to the database on my hosting company. Whats the best way to go about this?
I have created my sqlexpress database in Visual Studio 2005. When i go to SQL Server Management Studio Express I cannot open my database. It is not listed automatically and I get an error 'There is no editor for 'database name' Make sure the application for file type (.mdf) if installed.'
Because of numerous problems trying to get sqlexpress working, I uninstalled it with the intention of reinstalling (via Add or Remove Programs). However, now when I try to reinstall it, I get a message that the I am not making a changes so it won't let me install it.
I do have sql server 2005 developer's edition installed; is that the reason? and does that mean I cannot have both installed on the same machine?
Hi! i ask you some help..I should build a simple INSERT FORM in a SQLExpress database.. but clicking ADD I have this error :
Incorrect syntax near '='. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near '='.Source Error:
Line 38: conDatabase.Open() Line 39: Line 40: cmdInsert.ExecuteNonQuery() Line 41: Line 42: conDatabase.Close() some solution? the source code:
<%@ Page Language="VB" Debug="true"%> <%@ Import Namespace="System.Data"%> <%@ Import Namespace="System.Data.SqlClient"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> Sub Button_clic(ByVal s As Object, ByVal e As EventArgs) Dim conDatabase As SqlConnection Dim strInsert As String Dim cmdInsert As SqlCommand Dim myExecuteQuery As String Dim myExecuteCmd As SqlCommand
conDatabase = New SqlConnection("Data Source=.SQLEXPRESS;AttachDbFilename=C:Inetpubwwwroot esiApp_Datadatabase.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True")
This is by FAR, the most frustrating problem I have dealt with for a while.I have a project containing a SqlExpress database that I created in Visual Studio 2005. Everything works perfectly on my development machine. However, upon copying the site up to the webserver, I get an error stating:An attempt to attach an auto-named database for file D:ContentwwwFMakerApp_DataClassAd.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC shareI have read almost every article/forum post that resulted from a search with google. I also searched these forums, to no avail.Note - SQLExpress had just been downloaded and installed on the server, so it wasn't being used yet. Server is Windows Server 2003. Here are the following steps I have already taken:Used SSEUTIL.EXE to verify that another database of the same name was not already attachedUninstalled & reinstalled SQLExpress multiple timesTemporarily granted 'Full Control' permissions to 'Everyone' on the site folder to verify that it was not a permissions issue.Created a very simple website, with a new database, one page - with one listbox control, and a sqldatasource. Got the exact same error. Should rule out a problem with my application.Tried various flavors of the web.config connection string.Probably other stuff that I forgot about, but will add if I remember.The only things I could imagine being wrong are either a problem with my connectionString, or the fact that SQLExpress is installed on C:, and webstuff is on D: (Wasn't able to install SqlExpress to D: for some reason)Connection String <connectionStrings> <add name="ClassAdConnectionString" connectionString="Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|ClassAd.mdf;Integrated Security=true;User Instance=True" providerName="System.Data.SqlClient" /> </connectionStrings> So I have had like 12 strokes today. If anybody could help me get this fixed, I will spread tales of your awesomeness throughout the landsI have included some extra info below in case it is needed. Thanks, Adam.Entire Error An attempt to attach an auto-named database for file D:ContentwwwFMakerApp_DataClassAd.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: An attempt to attach an auto-named database for file D:ContentwwwFMakerApp_DataClassAd.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
Source Error:
Line 1705: }Line 1706: ClassAd.CategoriesDataTable dataTable = new ClassAd.CategoriesDataTable();Line 1707: this.Adapter.Fill(dataTable);Line 1708: return dataTable;Line 1709: }
Source File: c:WINDOWSMicrosoft.NETFrameworkv2.0.50727Temporary ASP.NET Filesforms9d7c504b4b8a576eApp_Code.3dq8tdsl.9.cs Line: 1707
I have a fresh install of sqlExpress and Management Studio Express on my test server. I want to restore my master database from backup.
From the command prompt I set the Sqlservr -s SQLEXPRESS -m
Then I opened another comand prompt and ran my SQLCMD script to restore the Master Database.
here is the sql script: RESTORE DATABASE [Master] FROM DISK = N'E:COPLEYNEWSDATABASEBACKUPMaster.bak' WITH FILE = 1, MOVE N'mastlog' TO N'C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLDATAMaster_1.ldf', NOUNLOAD, STATS = 10 GO
I recieve the following error.
Msg 3154, Level 16, State 4, Server COPLEYNEWSSQLEXPRESS, Line 1 The backup set holds a backup of a database other than the existing 'Master' dat abase. Msg 3013, Level 16, State 1, Server COPLEYNEWSSQLEXPRESS, Line 1
How do I restore a Master Database on SQL Express?
This is by FAR, the most frustrating problem I have dealt with for a while.
I have a project containing a SqlExpress database that I created in Visual Studio 2005. Everything works perfectly on my development machine. However, upon copying the site up to the webserver, I get an error stating:
An attempt to attach an auto-named database for fileD:ContentwwwFMakerApp_DataClassAd.mdf failed. A database with thesame name exists, or specified file cannot be opened, or it is locatedon UNC share
I have read almost every article/forum post that resulted from a search with google. I also searched these forums, to no avail.
Note - SQLExpress had just been downloaded and installed on the server, so it wasn't being used yet. Server is Windows Server 2003.
Here are the following steps I have already taken:
Used SSEUTIL.EXE to verify that another database of the same name was not already attached Uninstalled & reinstalled SQLExpress multiple times Temporarily granted 'Full Control' permissions to 'Everyone' on the site folder to verify that it was not a permissions issue. Created a very simple website, with a new database, one page - with one listbox control, and a sqldatasource. Got the exact same error. Should rule out a problem with my application. Tried various flavors of the web.config connection string. Probably other stuff that I forgot about, but will add if I remember.
The only things I could imagine being wrong are either a problem with my connectionString, or the fact that SQLExpress is installed on C:, and webstuff is on D: (Wasn't able to install SqlExpress to D: for some reason)
So I have had like 12 strokes today. If anybody could help me get this fixed, I will spread tales of your awesomeness throughout the lands
I have included some extra info below in case it is needed. Thanks, Adam.
Entire Error
An attempt to attach an auto-named database for fileD:ContentwwwFMakerApp_DataClassAd.mdf failed. A database with thesame name exists, or specified file cannot be opened, or it is locatedon UNC share. Description: Anunhandled exception occurred during the execution of the current webrequest. Please review the stack trace for more information about theerror and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException:An attempt to attach an auto-named database for fileD:ContentwwwFMakerApp_DataClassAd.mdf failed. A database with thesame name exists, or specified file cannot be opened, or it is locatedon UNC share.
Source Error:
Line 1705: } Line 1706: ClassAd.CategoriesDataTable dataTable = new ClassAd.CategoriesDataTable(); Line 1707: this.Adapter.Fill(dataTable); Line 1708: return dataTable; Line 1709: } Source File: c:WINDOWSMicrosoft.NETFrameworkv2.0.50727Temporary ASP.NET Filesforms9d7c504b4b8a576eApp_Code.3dq8tdsl.9.cs Line: 1707
Stack Trace:
[SqlException (0x80131904): An attempt to attach an auto-named database for file D:ContentwwwFMakerApp_DataClassAd.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.] System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +739123 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1956 System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +33 System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) +170 System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) +349 System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +181 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +170 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +359 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +28 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +424 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66 System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +496 System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +82 System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +105 System.Data.SqlClient.SqlConnection.Open() +111 System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +121 System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior) +162 System.Data.Common.DbDataAdapter.Fill(DataTable dataTable) +107 ClassAdTableAdapters.CategoriesTableAdapter.GetCategoriesByPropCode(String PropCode) in c:WINDOWSMicrosoft.NETFrameworkv2.0.50727Temporary ASP.NET Filesforms9d7c504b4b8a576eApp_Code.3dq8tdsl.9.cs:1707
Working on trying to support mutliple backend db's against a custom VB6 app. Right now the db is SqlExpress. It's relatively uncomplicated and I just want to move table structures and data over. Using the MySql Migration tool, I am able to authenticate as SA to a server-based instance of SqlExpress, however, only the MS-supplied databases appear as available databases; my databases don't appear. Can't seem to authenticate at all to any local instance of the database, either. Anyone done any successful migrations to MySql through their migration tool?
I am trying to complete a lab in the Microsoft self-paced training kit, Developing Web Applications with Microsoft Visual C# .NET.
They have provided an Access database named Contacts.mdb and a batch file named InstContacts.bat that uses InstContacts.sql to import the data.
I have installed SQLExpress, but when I run the batch file I get the following:
C:Microsoft Press...data>rem The following command line installs the Contact SQL database
C:Microsoft Press...data>osql -i InstContacts.Sql -E [SQL Native Client]Named Pipes Provider: Could not open a connection to SQL Server [2]. [SQL Native Client]Login timeout expired [SQL Native Client]An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections.
I have sqlexpress 2005 on my local machine - but my hoster has sql 2000 - so i used the DB publishing wizard to create the script and sent it over to them - they are now saying that they need a .bak file in 2000 to host my database - is this a bunch of horse hockey or not? if this is legit - any ideas on how I can create a .bak 2000 sql from sqlexpress 2005?
Hello everyone. i am using vwd 2005 express edition along with sqlexpress 2005. if i need to use database in my project. i click on database explorer and create a new table from the existing database. it is working very fine. But my problem is when ever i copy the project in my pen driveand try to use in another computer, the database doesnot gets copied when i copy my project folder. well i also tried to copy the tables from the database explorer but it does not happen.i tried to locate where does the database get stored in my computer.but i cant find where it resides..and even if i find which file to copy?i think there is log file and database file in some cases. can some body clarify me this scenario here.just tell me where can i find my database i m using in my project,so that i can copy it . and also whats the use of creating .mdf file in the project.?is this the better way of using database rather than creating using database explorer?confused?? thanks.jack..