Creating connection string of database created on different PC - asp.net

I am trying to use the database send by my friend. He has created it using Sql Server Management Studio. While including the .mdf file, I am getting an error message (I have mentioned the error at the end of the answer).
I think it is because of the difference in the connection strings. I am new to .NET so I just changed the name in the connection string,
From,
<add name="ApplicationServices" connectionString="Data Source=sheroz;Initial Catalog=FLEXIFORMDB;integrated security=SSPI"/>
</connectionStrings>
To,
<add name="ApplicationServices" connectionString="Data Source=Fahad-PC\Fahad;Initial Catalog=FLEXIFORMDB;integrated security=SSPI"/>
</connectionStrings>
Please help me out to make it work. Thanks in advance.
Error
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
------------------------------
Program Location:
at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String sqlCommand, ExecutionTypes executionType)
at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(StringCollection sqlCommands, ExecutionTypes executionType)
at Microsoft.SqlServer.Management.Smo.ExecutionManager.ExecuteNonQuery(StringCollection queries)
at Microsoft.SqlServer.Management.Smo.Server.AttachDatabaseWorker(String name, StringCollection files, String owner, AttachOptions attachOptions)
at Microsoft.SqlServer.Management.Smo.Server.AttachDatabase(String name, StringCollection files)
===================================
Unable to open the physical file "D:\FlexiFormWF\FlexiFormWF\FlexiFormDB.mdf". Operating system error 5: "5(Access is denied.)". (.Net SqlClient Data Provider)
------------------------------
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.00.1600&EvtSrc=MSSQLServer&EvtID=5120&LinkId=20476
------------------------------
Server Name: FAHAD-PC\MSSQL
Error Number: 5120

I think you have something with your permissions. At least, this quote from your error message suggests that:
Operating system error 5: "5(Access is denied.)"

Related

Times Ten LOB support

I have a passthrough connection in my c# application and I'm trying to do a select on a clob column which is in the database but not in-memory. But I get the following error, any ideas what I'm missing?
ORA-57000: TT5187: Caching LOBs from Oracle requires using an OCI client library provided by the TimesTen installation, or other versions of OCI client supported by TimesTen. -- file "bdbLob.c", lineno 224, procedure "ttBDbOraLobGetOraIdSnap"
As to Mat's comment above, I'm posting the solution for this problem. Created an entry in the config file as follows:
<oracle.dataaccess.client>
<settings>
<add name="DllPath" value="C:\oracle\bin"/>
<add name="FetchSize" value="65536"/>
<add name="PromotableTransaction" value="promotable"/>
<add name="StatementCacheSize" value="10"/>
</settings>
Dllpath is all that is needed to resolve the dll path.

Invalid value for key attachdbfilename

I try to run my asp net application in godaddy webserver and get error:
Exception Details: System.ArgumentException: Invalid value for key ‘attachdbfilename’.
My connection string:
<connectionStrings>
<remove name=”LocalSqlServer”/>
<add name=”LocalSqlServer” connectionString=”Data Source=(LocalDB)v11.0;Integrated Security=True;AttachDbFilename=|DataDirectory|Database.mdf” providerName=”System.Data.SqlClient”/>
</connectionStrings>
Any ideas how could I fix this? I dont have this error on my pc.
Ooops, I had the same problem, in my case i did not have LocalDB installed, so how about you check for that!!

Access database error "Could not find file"?

I have been using Access database as db of choice for a long time now and this is the first time I have run into the following error message:
Could not find file 'C:\Program Files\Common Files\Microsoft Shared\DevServer\10.0\dbo.mdb'
First, I don't have a db called dbo.mdb.
Second, the path to the db is defined in my web.config file thus:
<connectionStrings>
<add name="cingconstrng" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\inetpub\wwwroot\Roster\App_Data\AllStars.mdb" providerName="System.Data.OleDb" />
</connectionStrings>
Funniest part is that I am passing the connection string to some files without problem.
So, why is it different with this file?
Is it because I am inserting records into the db with with this file?
Any ideas is greatly appreciated. I have been working on this issue since last night and googling hasn't provided any solutions.
You can see this behavior if your SQL statements use namespaces:
INSERT INTO dbo.someTable ...
Remove the namespace and it should correct the issue.

Pre-Generating views to improve query performance in Entity Framework

I am trying to pre-generate view metadata for my Entity Framework project and have run across a problem on the last step when using this resource:
http://msdn.microsoft.com/en-us/library/bb896240.aspx
Everything else is compiling great, but I'm getting an error when I run my application, and I suspect it's due to a problem with the final step, 're-adding mapping and model files as embedded resources for ASP.NET projects.'
I'm receiving 'Unable to load the specified metadata resource.' and my connection string is as follows:
<add name="myEntities"
connectionString="metadata=
.\DataStructure.csdl|
.\DataStructure.ssdl|
.\DataStructure.msl;provider=System.Data.SqlClient;provider
connection string="Data Source=x;Initial Catalog=x;Persist Security Info=True;User ID=x;Password=x;MultipleActiveResultSets=True""
providerName="System.Data.EntityClient" />
It is suggested in the document that my connection string file should include the following but haven't been able to get it right in any configuration:
Metadata=res://<assemblyFullName>/<resourceName>;
Metadata=res://*/<resourceName>;
Metadata=res://*;
Assuming my assembly name is DataStructure.EF, how should my string be constructed?
http://msdn.microsoft.com/en-us/library/cc716756.aspx
<connectionStrings>
<add name="AdventureWorksEntities"
connectionString="metadata=.\AdventureWorks.csdl|.\AdventureWorks.ssdl|.\AdventureWorks.msl;
provider=System.Data.SqlClient;provider connection string='Data Source=localhost;
Initial Catalog=AdventureWorks;Integrated Security=True;Connection Timeout=60;
multipleactiveresultsets=true'" providerName="System.Data.EntityClient" />
</connectionStrings>
I compiled a full guide for anybody else having problems and published it here: http://kewney.com/posts/software-development/pre-generating-views-to-improve-query-performance-in-aspnet-mvc-3-entity-framework

ASP.NET Attempt to attach auto-named a database failed?

Parser Error Message: An attempt to
attach an auto-named database for file
D:\Projects\Damnation\Damnation.Website\Damnation.Website.Tracker\BugNET_WAP\App_Data\aspnetdb.mdf
failed. A database with the same name
exists, or specified file cannot be
opened, or it is located on UNC share.
Why could this be happening? My connection string doesn't use |DataDirectory|, it is:
<connectionStrings>
<add name="BugNET" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=dnmain;Integrated Security=True;"/>
</connectionStrings>
I get this error when I try to load default.aspx, after installing BugNET.
Apparently, and certainly for some obscure reason. There is a mistery connection string coming from... nowhere.
Problem solved adding a <clear/> tag.
<connectionStrings>
<clear/>
<add name="BugNET" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=dnmain;Integrated Security=True;"/>
</connectionStrings>
file
D:\Projects\Damnation\Damnation.Website\Damnation.Website.Tracker\BugNET_WAP\App_Data**aspnetdb.mdf**
failed.
This is the ASP.NET standard membership system here - not your "regular" database. There must be a second connection string somewhere that references this aspnetdb.mdf and tries to attach it from a file.
Search your solution for this file name - it must be somewhere!

Resources