Вы находитесь на странице: 1из 4

3/28/2015

Connecttoasqlserver2008databasefromawebapplicationCodeProject
11,333,088 members 36,876 online

Sign in

home

articles

quick answers

discussions

features

community

help

Searchforarticles,questions,tips

Ask a Question

All Questions All Unanswered

FAQ

Next

Connect to a sql server 2008 database from a web


application
See more:

ASP.NET

Rate this:

Hello,

I want to create a simple web application to learn asp.net.


I'm trying to practice a sql server 2008 in the same time and connect the application with the
database.

My question is how can i set a local database with my sql server management studio? and how i can
Top Experts in 24hrs
connect it with the asp.net application?
I saw a lot of tutorials on the net but i failed when i tried them, i had lot of errors and i'm new with
sql server and asp.net and i could not solve any of them.
0 OriginalGriff

1 Sergey Alexandrovich Kryukov


I'm getting the following error when i'm trying to connect to the database from the code:
2 Abhinav S
Login failed for user ''

3 Afzaal Ahmad Zeeshan


And the following error when i try to set the database log in and permissions:
4 Tadit Dash

TITLE: Microsoft SQL Server Management Studio

Top Experts this month


Alter failed for User 'dbo'. Microsoft.SqlServer.Smo

For help, click: http://go.microsoft.com/fwlink?


0 Sergey Alexandrovich Kryukov
ProdName=Microsoft+SQL+Server&ProdVer=10.50.1447.4+KJ_RTM.100213
1 OriginalGriff
0103+&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Alter+User&LinkId=20476

2 Peter Leow

3 Kornfeld Eliyahu Peter


ADDITIONAL INFORMATION:
4 Tadit Dash

An exception occurred while executing a TransactSQL statement or batch.


Microsoft.SqlServer.ConnectionInfo

Cannot alter the user 'dbo'. Microsoft SQL Server, Error: 15150

For help, click: http://go.microsoft.com/fwlink?


ProdName=Microsoft+SQL+Server&ProdVer=09.00.5000&EvtSrc=MSSQLServer&EvtID=15150&LinkId=20476

BUTTONS:

OK

Do anyone know a good tutorial that leads me step by step?

http://www.codeproject.com/Questions/521806/Connectplustoplusaplussqlplusserverplusplusdat

295
255
209
200
125

9,301
8,160
4,839
3,210
2,267

1/4

3/28/2015

Connecttoasqlserver2008databasefromawebapplicationCodeProject

Thanks

Posted 4Jan13 9:49am Edited 4Jan13 9:57am v2


Brainy Girl 436
Abhishek Pant 18K

Add a Solution

2 solutions

Top Rated

Solution 1

Most Recent

Rate this:

In order to connect to the database, you need to use a SqlConnection[^] have a look at the example
in the end.

To get the connection string right, visit http://www.connectionstrings.com/sqlserver2008[^]

When you use local Sql Server instance, you can define a name of the computer or you can refer it
using . dot which is a shortcut for local computer in connection strings.

Not sure why you're trying to alter any user. When you connect to the database, you either use Sql
Server user authentication which means that you define a user name with a password in order to
connect to the database or you use windows authentication which again means that your current
credentials will be used for the connection.

If you use Windows authentication, notice that the credentials that are used with IIS are used for the
connection. For example, have a look at Setting up SQL Server 2008 for an ASP.NET website on IIS
7.0[^]

Posted 4Jan13 10:05am


Mika Wendelius 252.2K

Comments
Espen Harlinn at 6Jan13 9:14am
5'ed!

Mika Wendelius at 6Jan13 10:56am


Thanks :

Solution 2

Rate this:

http://blog.sqlauthority.com/2008/11/02/sqlserverfixerrorloginfailedforuserusernamethe
userisnotassociatedwithatrustedsqlserverconnection/[^]

Please refer above link.

Posted 4Jan13 10:10am


Member 9581488 1.8K

Edited 4Jan13 10:19am v2


Andr Kraak 90.2K

http://www.codeproject.com/Questions/521806/Connectplustoplusaplussqlplusserverplusplusdat

2/4

3/28/2015

Connecttoasqlserver2008databasefromawebapplicationCodeProject

Add your solution here


B I U S small BIG code var < > & link [^] encode untab indent outdent

Preview

Existing Members

...or Join us

Sign in to your account


Your Email

Download, Vote, Comment, Publish.

Password

Your Email

Optional Password
Forgot your password?

I have read and agree to the Terms of Service


and Privacy Policy
Please subscribe me to the CodeProject
newsletters

Submit your solution!


When answering a question please:
1. Read the question carefully.
2. Understand that English isn't everyone's first language so be lenient of bad spelling and
grammar.
3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the
question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.

This content, along with any associated source code and files, is licensed under The Code Project Open License CPOL

http://www.codeproject.com/Questions/521806/Connectplustoplusaplussqlplusserverplusplusdat

3/4

3/28/2015

Advertise | Privacy | Mobile


Web03 | 2.8.150327.1 | Last Updated 4 Jan 2013

Connecttoasqlserver2008databasefromawebapplicationCodeProject

Layout: fixed | fluid

Copyright CodeProject, 19992015


All Rights Reserved. Terms of Service

CodeProject, 503250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 4168498900 x 100

http://www.codeproject.com/Questions/521806/Connectplustoplusaplussqlplusserverplusplusdat

4/4

Вам также может понравиться