4
11,333,088 members ﴾36,876 online﴿ Sign in home articles discussions features community help Search for articles, questions, tips Ask a Question All Questions All Unanswered FAQ Next Connect to a sql server 2008 database from a web application Rate this: See more: 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 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. I'm getting the following error when i'm trying to connect to the database from the code: Login failed for user '' And the following error when i try to set the database log in and permissions: TITLE: Microsoft SQL Server Management Studio ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ Alter failed for User 'dbo'. ﴾Microsoft.SqlServer.Smo﴿ For help, click: http://go.microsoft.com/fwlink? ProdName=Microsoft+SQL+Server&ProdVer=10.50.1447.4+﴾﴾KJ_RTM﴿.100213‐ 0103+﴿&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationException ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ ADDITIONAL INFORMATION: An exception occurred while executing a Transact‐SQL 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&Link ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ BUTTONS: OK ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐ Do anyone know a good tutorial that leads me step by step? ASP.NET Top Experts in 24hrs 0 OriginalGriff 295 1 Sergey Alexandrovich Kryukov 255 2 Abhinav S 209 3 Afzaal Ahmad Zeeshan 200 4 Tadit Dash ﴾ତଡ ମାର ଦାଶ﴿ 125 Top Experts this month 0 Sergey Alexandrovich Kryukov 9,301 1 OriginalGriff 8,160 2 Peter Leow 4,839 3 Kornfeld Eliyahu Peter 3,210 4 Tadit Dash ﴾ତଡ ମାର ଦାଶ﴿ 2,267 quick answers

Connect to a SQL Server 2008 Database From a Web Application - CodeProject

  • Upload
    nazeer

  • View
    221

  • Download
    1

Embed Size (px)

DESCRIPTION

mmmm

Citation preview

  • 3/28/2015 Connecttoasqlserver2008databasefromawebapplicationCodeProject

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

    11,333,088 members 36,876 online

    Sign in

    home articles 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 webapplication

    Rate this:See more:

    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 thedatabase.My question is how can i set a local database with my sql server management studio? and how i canconnect 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 withsql server and asp.net and i could not solve any of them.I'm getting the following error when i'm trying to connect to the database from the code:Login failed for user ''And the following error when i try to set the database log in and permissions:TITLE: Microsoft SQL Server Management StudioAlter failed for User 'dbo'. Microsoft.SqlServer.SmoFor help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.50.1447.4+KJ_RTM.1002130103+&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Alter+User&LinkId=20476ADDITIONAL INFORMATION:An exception occurred while executing a TransactSQL statement or batch.Microsoft.SqlServer.ConnectionInfoCannot alter the user 'dbo'. Microsoft SQL Server, Error: 15150For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.5000&EvtSrc=MSSQLServer&EvtID=15150&LinkId=20476BUTTONS:OKDo anyone know a good tutorial that leads me step by step?

    ASP.NET

    Top Experts in 24hrs

    0 OriginalGriff 295

    1 Sergey Alexandrovich Kryukov 255

    2 Abhinav S 209

    3 Afzaal Ahmad Zeeshan 200

    4 Tadit Dash 125

    Top Experts this month

    0 Sergey Alexandrovich Kryukov 9,301

    1 OriginalGriff 8,160

    2 Peter Leow 4,839

    3 Kornfeld Eliyahu Peter 3,210

    4 Tadit Dash 2,267

    quick answers

  • 3/28/2015 Connecttoasqlserver2008databasefromawebapplicationCodeProject

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

    Posted 4Jan13 9:49amBrainy Girl 436

    Edited 4Jan13 9:57amAbhishek Pant 18K

    v2

    2 solutions Top Rated Most Recent

    Rate this:Solution 1

    Posted 4Jan13 10:05amMika Wendelius 252.2K

    Espen Harlinn at 6Jan13 9:14am

    Mika Wendelius at 6Jan13 10:56am

    Rate this:Solution 2

    Posted 4Jan13 10:10amMember 9581488 1.8K

    Edited 4Jan13 10:19amAndr Kraak 90.2K

    v2

    Add a Solution

    In order to connect to the database, you need to use a SqlConnection[^] have a look at the examplein 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 itusing . 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 SqlServer user authentication which means that you define a user name with a password in order toconnect to the database or you use windows authentication which again means that your currentcredentials will be used for the connection.If you use Windows authentication, notice that the credentials that are used with IIS are used for theconnection. For example, have a look at Setting up SQL Server 2008 for an ASP.NET website on IIS7.0[^]

    Comments

    5'ed!

    Thanks :

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

    Please refer above link.

    Thanks

  • 3/28/2015 Connecttoasqlserver2008databasefromawebapplicationCodeProject

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

    Add your solution here

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

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

    Preview

    Existing MembersSign in to your account

    ...or Join usDownload, Vote, Comment, Publish.

    Your Email

    Password

    Forgot your password?

    Your Email

    Optional Password

    I have read and agree to the Terms of Serviceand Privacy Policy

    Please subscribe me to the CodeProjectnewsletters

    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 andgrammar.

    3. If a question is poorly phrased then either ask for clarification, ignore it, or edit thequestion and fix the problem. Insults are not welcome.

    Let's work to help developers, not make them feel stupid.

    code

  • 3/28/2015 Connecttoasqlserver2008databasefromawebapplicationCodeProject

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

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

    Advertise | Privacy | Mobile Web03 | 2.8.150327.1 | Last Updated 4 Jan 2013

    Copyright CodeProject, 19992015 All Rights Reserved. Terms of Service

    Layout: fixed | fluid