Using SQL on Development Machine

J

Jonathan Wood

William,
Change the "(localhost)" to "." or "(local)" to refer to the local system.

Either of these changes the error to: "Cannot open database "BlackBelt"
requested by the login. The login failed. Login failed for user
'Jonathan-PC\Jonathan'."

Note that (localhost) worked on my other computer and I see localhost used
in several examples. So there's yet something else that doesn't make sense.
(I'm sure you discuss this in your book.) But the error seems more
meaningful this time. If I right-click on the database (BlackBelt.mdf) in
the Server Explorer and select the Modify Connection command, I see 'Use
Windows Authentication' is selected, for which I obviously have correct
authentication. And if I click 'Test Connection' from this same dialog, it
reports that the connection succeeded.
This also assumes that you have rights to the default database
"BlackBelt".

I created the database. I can see and open it in VS. I'm running on Vista as
an administrator. So, no, I guess I don't. :-/
Is the service started? Start | SQL Server Configuration Manager to check.

Err...

SQL Server 2005 Services
- SQL Server (SQLEXPRESS) = Running
- SQL Server Browser = Stopped
SQL Server 2005 Network Configuration
- Protocols for SQLEXPRESS
- Shared Memory = Enabled
- Named Pipes = Disabled
- TCP/IP = Disabled
- VIA = Disabled
SQL Native Client Configuration
- Client Protocols
- Shared Memory = Enabled
- Named Pipes = Enabled
- TCP/IP = Enabled
- VIA = Disabled
Aliases
(Empty)
See Chapter 9 (and make sure to download the new PDF version).

PDF version of chapter 9?

Thanks.
 
N

Norman Yuan

No offence. All your posts indicate that you want to get on coding your app
quick, but unwilling to spend time on database server study, although you
need to use one.

Database server, such as SQL Server, MySQL and Oracle, itself is a VERY
complicated server software and you MUST do the some very basic study before
you can use it in meaningful way. Take the error you ran int as an example.
It has been asked over in different NGs for thousands of times (if not
more). The main reason for that is newbies just jump on .NET coding without
due study on what SQL Server is. As developer, if you want to access any
database server, you need to know how to access it with appropriate security
requirements met. Nowadays, when a server software (Wondows server OS, SQL
Server, ....) is installed, by default, all its links to outside (hence the
potential security holes) are blocked. You need to configure it to open
those links/holes individually when only you need it.

As for SQL Server/Express, after installing it, you ned to open it to the
network if you are to access it from network; you need to create needed SQL
Server logins, unless you only access it as local admin (on Vista, even
local admin does not gain access to it automatically). If you need to use
user/password to gain access, you need to enable mixed security mode... It
is absolutely no go to use SQL Server/Express (or other database server, for
that matter) without knowing such basic things, IMO. Sometimes, one can get
away without knowing too much on his developing machine, because, the
developer verylikely is the local admin on the box. But it would be certain
that his application would not run once deployed to other computer, or not
even able to be installed.

So, sitting down for a couple of days, or a week, studying on one of the
database server of your choice before jumping to the coding would definitely
paid off for the time spent, and all your basic questions would be answered
by yourself.

Sorry. I really felt this is the better direction and easiest way to go.
 
J

Jonathan Wood

Norman,
No offence. All your posts indicate that you want to get on coding your
app quick, but unwilling to spend time on database server study, although
you need to use one.

I've spent many years helping others in these newsgroups on various
programming topics, and so when I am trying to do the very thing you suggest
(learn about SQL Server), I look to see if anyone is willing and able to
help me in these newsgroups regarding a few specific issues I'm having. It
is my view that this is the very purpose of the newsgroups.

I've purchased several books that include detailed information and will
continue to read them as I'm able. But the fact is that all development has
now stopped because I cannot get an app that was working on another computer
to work on my new one. .NET requires me to learn many new technologies and
SQL Server is only one of them.

I'm sorry if you see something wrong with all this.
As for SQL Server/Express, after installing it, you ned to open it to the
network if you are to access it from network;

I'm not accessing it from a network. And I'm able to access it from within
VS. So I really don't see why my application (running on my desktop) should
be able to as well.
 
J

Jonathan Wood

I was finally able to get this working this morning. I did so by copying the
connection string from the database properties, which changed it from:

"Server=.\SQLEXPRESS;Integrated security=SSPI;Initial Catalog=BlackBelt"

to:

"Data
Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Jonathan\Documents\Visual
Studio 2005\WebSites\BlackBelt\App_Data\BlackBelt.mdf;Integrated
Security=True;User Instance=True"

If anyone sees any obvious reasons why the second worked while the first
does not, I'd love to hear about it. Otherwise, I can continue development
and, hopefully, I'll have gained a better understanding of why it did not
work before I have to move my database to a server or another computer.

Thanks.

Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
 
N

Norman Yuan

You finally got it to work, because you used SQL Server Express' User
Instance, which saved you from learning the SQL Server's security. This is
both good thing and bad thing.

User Instance is only supported by SQL Server Express, not by all other
edition of SQL Server2005. So, if you did not fully understand what User
Insdtance means, your app most likely does not work once you install to
other computer, unless you specificly design your app use User Instance. For
example, the database on a USER INSTANCE cannot be shared with other users.

Problem like you can connect to SQL Server from VS, but not from your app,
is typical when not fully understanding SQL Server security.

Really, I am trying to help here, and I do think the most easiest and
straightforward help to to point out what you need in order to user database
server, such as SQL Server, which is to study some very basic and necessary
about SQL Server, rather than simply giving you a ConnectionString that
works.
 
J

Jonathan Wood

Norman,
You finally got it to work, because you used SQL Server Express' User
Instance, which saved you from learning the SQL Server's security. This is
both good thing and bad thing.

User Instance is only supported by SQL Server Express, not by all other
edition of SQL Server2005. So, if you did not fully understand what User
Insdtance means, your app most likely does not work once you install to
other computer, unless you specificly design your app use User Instance.
For example, the database on a USER INSTANCE cannot be shared with other
users.

Problem like you can connect to SQL Server from VS, but not from your app,
is typical when not fully understanding SQL Server security.

Really, I am trying to help here, and I do think the most easiest and
straightforward help to to point out what you need in order to user
database server, such as SQL Server, which is to study some very basic and
necessary about SQL Server, rather than simply giving you a
ConnectionString that works.

As I've stated several times that, right now, I just want to be able to run
the application so I can continue development. Since the application will
eventually be deployed on a hosting server, I will need a different
connection string anyway. So I honestly do not see how this is bad in any
way. I will not use the same connection string when the application goes
live.

As far as learning more about SQL Server, I addressed that in my other email
to you.
 
W

William Vaughn

As Mr. Yuan pointed out, your lack of understanding is leading you down a
development path that will frustrate you once you try to deploy. The way SQL
Server is handled in the User Instance = True scenario is very (very)
different than how it's handled in an ASP shared database environment. Many
of us on this list will gladly give you the shovel to dig your grave or the
rope to hang you--others like Mr. Yuan (and I) feel uncomfortable giving you
something that is not right for your situation.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant, Dad, Grandpa
Microsoft MVP
INETA Speaker
www.betav.com
www.betav.com/blog/billva
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------
 
J

Jonathan Wood

William,
As Mr. Yuan pointed out, your lack of understanding is leading you down a
development path that will frustrate you once you try to deploy. The way
SQL Server is handled in the User Instance = True scenario is very (very)
different than how it's handled in an ASP shared database environment.
Many of us on this list will gladly give you the shovel to dig your grave
or the rope to hang you--others like Mr. Yuan (and I) feel uncomfortable
giving you something that is not right for your situation.

I guess I'll probably just have to agree to disagree with anyone who cannot
see any value whatsoever in getting my application to at least run as I
continue to study, learn and increase my understanding. This goes double
given that no one could tell me how else to connect to my database.

As I said, I've spent many years helping people out in various programming
newsgroups. I just am not getting how telling me what not to do is that
helpful.

Thanks anyway.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top