Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old December 17th, 2003, 09:12 AM
StrawberryField StrawberryField is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 3 StrawberryField User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 25 sec
Reputation Power: 0
ASP.NET & SQL Server (Getting Started)

Good day everyone.

I'm new to SQL/ASP.NET and the Visual Studio environment.

I'm trying to get a simple example to work from a book that I'm learning from:
"Moving to ASP.NET: Web Development with VB.NET"

I have SQL Server 7.0 installed on my Windows 2000
desktop and I'm working in Visual Studio.Net.

I have windows authentication security mode on SQL Server.

I'm performing a simple page that reads data from
the database and I'm getting this error:

---error---
Login failed for user 'sa'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: Login failed for user 'sa'.
---error---

I've been told that I need to have SQL Server authenticate the "ASP.NET _process", but I'm not sure how to do this, nor how to verify that this authentication is working properly.

Any help is greatly appreciated!

Reply With Quote
  #2  
Old December 17th, 2003, 09:20 AM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,776 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 27 m 42 sec
Reputation Power: 470
1) For SQL Server 7.0 You need to use the SqlConnection object...not OleDb.

Create a reference to
System.Data.SqlClient

The best way to do it would be to create a new user in sql server. Then give that user rights to whatever database you are wanting to work with.
Code:
Dim objConn As SqlConnection
Dim objCmd As SqlCommand
Dim reader As Reader

'Set the Connection object
objConn = New SqlConnection("Driver={SQL Server};User ID=username;PWD=password;Database=dbName")

'Set the Command object
objCmd=New SqlCommand("SELECT * FROM TableName", objConn)
Try
   objConn.Open()
   reader = objCmd.ExecuteReader()

   While(reader.Read())
      Response.write(Convert.ToString(reader("fieldName")))
   End While

   reader.Close()
   objConn.Close()
Catch ex As Exception
   Response.write("Error: " & ex.Message)
End Try

Reply With Quote
  #3  
Old December 17th, 2003, 09:47 AM
StrawberryField StrawberryField is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 3 StrawberryField User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 25 sec
Reputation Power: 0
Memnoch,

thanks for replying.

Few things.
1. Actually, I'm not sure that I'm running 7.0. I'm not even sure how I can determine what version of SQL Server I'm running. When I'm in enterprise manager, the "about SQL Server enterprise manager" box says version 8.00.194.

So can I use the OleDbConnection?

2. I have attempted to give a user rights to the database. This is what I did:
- Local SQL Server > Securty > Logins: new login Test
- Test is Standard with SQL Server Authentication
- Test was given access to one database, called "HiFlyers"

---error--in--more--detail----
Server Error in '/HiFlyers' Application.
--------------------------------------------------------------------------------

Login failed for user 'Test'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: Login failed for user 'Test'.

Source Error:


Line 23: 'Put user code to initialize the page here
Line 24: Dim CN As New OleDbConnection("Provider=SQLOLEDB.1;Data Source=(local);Initial Catalog=HiFlyers;User ID=Test;")
Line 25: CN.Open()
Line 26: Dim CM As New OleDbCommand( _
Line 27: "SELECT AircraftID, Registration, Manuf, Model FROM Aircraft", CN)


Source File: c:\inetpub\wwwroot\HiFlyers\AircraftList.aspx.vb Line: 25

Stack Trace:


[OleDbException (0x80040e4d): Login failed for user 'Test'.]
System.Data.OleDb.OleDbConnection.ProcessResults(I nt32 hr) +20
System.Data.OleDb.OleDbConnection.InitializeProvid er() +57
System.Data.OleDb.OleDbConnection.Open() +203
HiFlyers.AircraftList.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\HiFlyers\AircraftList.aspx.vb:2 5
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573
---error--in--more--detail----

Again, I'm very grateful for
any help!

Reply With Quote
  #4  
Old December 17th, 2003, 10:37 AM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,776 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 27 m 42 sec
Reputation Power: 470
To check the version, open query analyzer and type
Code:
SELECT @@Version

Version 8.0xxx seems like SQL Server 2000

For SQL Server 7.0 and 2000 use System.Data.SqlClient
For SQL Server 6.5 or earlier use System.Data.OleDb

2) Did you give the Test login a password?
Steps to add a new user
1) Security>New Login

On General Tab
2) Type the username
3) Select SQL Server Authentication and type in the password
4) From the database drop down select the default database for this user.

On Database Access Tab
Check the "Permit" box next to the default database for this user.
Then check the db_owner box for database roles below that.
Then confirm the password for the user.

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > ASP.NET & SQL Server (Getting Started)


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT