Problem adding data connection in C#

I installed VS 2005 Express (C# + MSSQL 2005Express + Management Studio for MSSQL 2005Express) and encounter a problem trying to add new data connection. I select .NET Framework data provider for MS SQL server, database file, witch a can open with Management studio and when I test connection I get an error “User does not have permission to perform this operation”. I set all possible permissions (I guess) within the database and no change. I am stuck. Anyone can help me please.
[481 byte] By [bromba] at [2008-2-7]
# 1

I think I know what's going on here. The first thing you should know is that with MSSQL 2005 (SSE), there are 2 fundamental ways to connect to it. The first is the traditional way via a connection where you specify the server and the login credentials, etc. The second way is via a "local data" type scenario with user instances. When you use user instances, you work with the database like a file. Much in the way that you would work with an MDB.

The C# Express *Designer* only allows you to work with MDF files as User Instances or in a local data scenario. It does not allow the traditional style connections via the designer. (You can connect via your code in a traditional style.) The designers in the Express SKUs in general do not allow for connections to databases via the traditional style connection. The one exception is the Web Express SKU which normally doesn't have data local to where the app is running.

The way you use the MDF in a local data scenario is that you add it to you your project. It will generate a connection string that has "user instance = true" and other things in it. Notably, it will *not* have a logical database name, it *will* have a database file name and relative path. And, you can copy the MDF around with your project. When you build your application, it will make a copy of the MDF and put it in the exe directory, etc. If you want to use the MDF in this type of scenario, you may need to formally detach the MDF in SSMS 2005 Express first since SSMS normally takes an exclusive lock on the MDF.

LanceDelano at 2007-9-8 > top of Msdn Tech,Visual Studio Express Editions,Visual C# 2005 Express Edition...
# 2
I create my local database from within Visual Studio this way (Its different but may trigger something for you)
1) Create a new project
2) In "Solution Explorer" Right-Click on your project and choose Add > New Item (Or from the menu Project > Add New Item)
3) Choose SQL Database, and name it what you want. Click the Add button
4) When the "Data Source Configuration" wizard pops up, just click cancel. You wont need that yet...
5) On the menu go to View > Other Windows > Database Explorer.
Expand the tree for the visual representation of your db.
6) Right click on the "Tables" folder to add the tables that you want. (Once you have you tables you can right click on them to "Show table data" if you want to manually add some data)
7) Once you get all of your tables, right click on the "Database Diagrams" and choose Add New Diagram. (Answer yes if it asks you to create files) - Select the tables that you want in your diagram and then you can set all of your relationships here...
8) once your done with the diagram - you can go to your data sources to "Add new data source"... it should default to the db item that you added to the project... Now you can do the wizard for the dataset...
Note: This creates the db in the root folder of the project. If you select the db in Solution Explorer and view the properties on it, You'll notice that the "Copy to output directory" is set to "Copy Always"... you'll want to keep that in mind (I usually set mine to Copy if newer)
The thing to remember is: if your editing the db from within visual studio (add tables, relationships, adding data) your working on the db in the root... If you run your program, then your working on the db in the output directory....
rekab at 2007-9-8 > top of Msdn Tech,Visual Studio Express Editions,Visual C# 2005 Express Edition...