•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C# section within the Software Development category of DaniWeb, a massive community of 456,589 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,593 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C# advertiser: Programming Forums
Views: 4065 | Replies: 3
![]() |
•
•
Join Date: Aug 2007
Location: Gunnison, Colorado
Posts: 57
Reputation:
Rep Power: 2
Solved Threads: 1
I'm using C# Express and SQL Server Express. I can connect to sample databses I have downloaded to the default location (..\MMSQL.1\MSSQL\DATA) but I cannot connect to a new database I create using SQL Server. The error is "You don't have permission to open this file. Contact the owner or administrator to obtain permission". I'm the owner, of course.
I can create a new database directly in a C# project and put it together, but I cannot see it from SQL Server.
I can connect to Access databases without any problems.
Is this a limitation built into C# Express and SQL Explorer Express because they are essentially free samples, or am I missing something obvious?
I can create a new database directly in a C# project and put it together, but I cannot see it from SQL Server.
I can connect to Access databases without any problems.
Is this a limitation built into C# Express and SQL Explorer Express because they are essentially free samples, or am I missing something obvious?
•
•
Join Date: Nov 2006
Location: Bonners Ferry, ID
Posts: 280
Reputation:
Rep Power: 3
Solved Threads: 39
There are a few things for you to look at.
Where the databases created using the "sa" administrator account ? IOW, who is the owner of the database, and was the Login account you are using to log in to the server have permission to use the new DB.
The error you are getting is strictly an SQL error. Has nothing to do with C#. Post the code you are using to attach the database, assign permissions, and then connect, and someone will help.
Where the databases created using the "sa" administrator account ? IOW, who is the owner of the database, and was the Login account you are using to log in to the server have permission to use the new DB.
The error you are getting is strictly an SQL error. Has nothing to do with C#. Post the code you are using to attach the database, assign permissions, and then connect, and someone will help.
•
•
Join Date: Aug 2007
Location: Gunnison, Colorado
Posts: 57
Reputation:
Rep Power: 2
Solved Threads: 1
I am not directly using SQL, but I assume the C# environment is. I am from a Delphi/Access environment. C# has been no problem but SQL Server has proved a puzzel. I will try to give an exact description of what I am doing:
In SQL Server Express
Right-click Databases and create a new one.
In the NewDatabase dialog, Owner is set to <default>.
Check for other owners. In Select Database Owner dialog, there are no objects listed. Do I need to create a user first?
Create the new database using Owner of <default>, create a new table and run a select query. No error, and the results pane displays the fields from the table. So I assume I am properly connected in SQL Server.
Go to C# Express, create a new project and use Data | Add new data source wizard. In the connection dialog, click the New connection button. In the Add connection dialog Data source is set to Microsoft SQL Server Database File (SqlClient), use Windows authentication, navigate to the database, and select it. I get the error listed in my first post. I have also tried using SQL Server Authentication with my usual passwords.
In SQL Server Express
Right-click Databases and create a new one.
In the NewDatabase dialog, Owner is set to <default>.
Check for other owners. In Select Database Owner dialog, there are no objects listed. Do I need to create a user first?
Create the new database using Owner of <default>, create a new table and run a select query. No error, and the results pane displays the fields from the table. So I assume I am properly connected in SQL Server.
Go to C# Express, create a new project and use Data | Add new data source wizard. In the connection dialog, click the New connection button. In the Add connection dialog Data source is set to Microsoft SQL Server Database File (SqlClient), use Windows authentication, navigate to the database, and select it. I get the error listed in my first post. I have also tried using SQL Server Authentication with my usual passwords.
•
•
Join Date: Nov 2006
Location: Bonners Ferry, ID
Posts: 280
Reputation:
Rep Power: 3
Solved Threads: 39
I too am from the Delphi world. Have you tried using Delphi to access this database ?
As a test, can you see if you can access the database through code.
Finally, what does your connection string look like ?
In the above sample code, replace the SHAWHP\\SQLEXPRESS
with your own server, and the SoftwareInventory catalog with your
own and see if that works.
As a test, can you see if you can access the database through code.
private void Form1_Load(object sender, EventArgs e) { SqlConnection conn = new SqlConnection(); conn.ConnectionString = "Data Source=SHAWHP\\SQLEXPRESS;Initial Catalog=SoftwareInventory;Integrated Security=True"; conn.Open(); conn.Close(); }
Finally, what does your connection string look like ?
In the above sample code, replace the SHAWHP\\SQLEXPRESS
with your own server, and the SoftwareInventory catalog with your
own and see if that works.
![]() |
•
•
•
•
•
•
•
•
DaniWeb C# Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
ad advertising ajax architecture asp backup beta business centro crash daniweb database dell developer development doubleclick enterprise google hacker internet linux longhorn mail microsoft mmorpg msdn news novell office open qmail red hat rhel security server smtp software source sql survey suse vista windows windows server
- Database connectivity for sql server express edition 2005 (ASP.NET)
- Connecting to SQL server DB from VB.NET app (VB.NET)
- connecting to an sql server (VB.NET)
- sql server express edition (C#)
- Help needed: Connecting to sql server database (VB.NET)
Other Threads in the C# Forum
- Previous Thread: Emulator Data UpLoading
- Next Thread: C# - OleDbDataReader return a value


Linear Mode