Solved

Cannot open database "ASPNETDB" requested by the login. The login failed. Login failed for user 'B47\Kola'.

Posted on 2008-06-25
5
1,931 Views
Last Modified: 2013-11-26
Please i cant seem to find out what i and doing wrong, i am getting the error "Cannot open database "ASPNETDB" requested by the login. The login failed. Login failed for user 'B47\Kola'."


i am using a stored procedure to add data from form to SQL SERVER 2005, i have attached below the snippets stored procedure, Addevent.aspx.cs, and web config respectively

Please can some help

thanks

ALTER PROCEDURE dbo.StoredProcedure1 

	/*

	(

	@parameter1 int = 5,

	@parameter2 datatype OUTPUT

	)

	*/

	

	@EventId varchar(50),

	@UserId varchar(50),

	@CatId varchar(50),

	@EventName varchar(50),

	@Organiser varchar(50),

	@ContactEmail varchar(50),

	@ShortText varchar(50),

	@LongText varchar(50),

	@Address varchar(50),

	@City char(30),

	@Price Money,

	@Thumbnail varchar(20),

	@eImage varchar(20),

	@eDate datetime,

	@eTime varchar(10),

	@Venue varchar(50),

	@Tickets varchar(50),

	@Age char(10)

	

AS
 

INSERT INTO Events

(EventId, UserId, CatId, EventName, Organiser, ContactEmail, ShortText, LongText, Address, City, Price, Thumbnail, eImage, eDate, eTime, Venue, Tickets, Age)

	/* SET NOCOUNT ON */ 

	

	VALUES(@EventId, @UserId, @CatId, @EventName, @Organiser, @ContactEmail, @ShortText, @LongText, @Address, @City, @Price, @Thumbnail, @eImage, @eDate, @eTime, @Venue, @Tickets, @Age)

	RETURN
 
 

/////////////////////////////////////////////////
 

public partial class AddEvent : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

       {
 

           if (!IsPostBack)

           {

               MembershipUser myObject = Membership.GetUser();

               string UserID = myObject.ProviderUserKey.ToString();

               Label6.Text = UserID;

           }

    }

    protected void Button1_Click(object sender, EventArgs e)

    {
 

          

               

        SqlCommand cmd = new SqlCommand("StoredProcedure1 ", new SqlConnection(ConfigurationManager.AppSettings["ConnString"]));

        cmd.CommandType = CommandType.StoredProcedure;
 
 

        /*cmd.Parameters.AddWithValue("@UserID", UserID);*/

        cmd.Parameters.AddWithValue("@EventName", eName.Text);

        cmd.Parameters.AddWithValue("@city", Organiser.Text);

        cmd.Parameters.AddWithValue("@ContactEmail", ContactEmail.Text);

        cmd.Parameters.AddWithValue("ShortText", Short.Text);

        cmd.Parameters.AddWithValue("@LongText", Long.Text);

        cmd.Parameters.AddWithValue("@Address", Address.Text);

        cmd.Parameters.AddWithValue("@City", City.Text);

        cmd.Parameters.AddWithValue("@Price", Price.Text);

        cmd.Parameters.AddWithValue("@eDate", Date.Text);

        cmd.Parameters.AddWithValue("@eTime", Time.Text);

        cmd.Parameters.AddWithValue("@Venue", Venue.Text);

        cmd.Parameters.AddWithValue("@Tickets", Tickets.Text);

        /*cmd.Parameters.AddWithValue("@Age", Age.SelectedIndex.ToString);*/

        /*cmd.Parameters.AddWithValue("@name", txtName.Text);

        cmd.Parameters.AddWithValue("@city", txtCity.Text);

        cmd.Parameters.AddWithValue("@name", txtName.Text);

        cmd.Parameters.AddWithValue("@city", txtCity.Text);*/
 

        cmd.Connection.Open();

        cmd.ExecuteNonQuery();

        cmd.Connection.Close();

    

     

    }

}
 
 

////////////////////////////////////////////////////
 

</system.web.extensions>

	<connectionStrings>

		<add name ="ASPNETDBConnectionString1" connectionString ="Data Source= .\SQLEXPRESS; Integrated Security = True;  Initial Catalog= ASPNETDB"  providerName ="System.Data.SqlClient"/>		

		

	</connectionStrings>

	<system.net>

		<mailSettings>

			<smtp>

				<network host="localhost"/>

				

			</smtp>

			

		</mailSettings>

		

	</system.net>

	
 

  <system.webServer>

    <validation validateIntegratedModeConfiguration="false"/>

    <modules>

      <add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

    </modules>

    <handlers>

      <remove name="WebServiceHandlerFactory-Integrated" />

      <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode"

           type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

      <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode"

           type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

      <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

    </handlers>

  </system.webServer>
 

	<appSettings>

		<add key="ConnString" value="Data Source=.\SQLEXPRESS;Initial Catalog=ASPNETDB;Integrated Security=True"/>

	</appSettings>

</configuration>

Open in new window

0
Comment
Question by:kladtek
  • 3
  • 2
5 Comments
 
LVL 21

Accepted Solution

by:
naspinski earned 500 total points
Comment Utility
look in your SQL Server Management Studio.

Under Security->Logins, make sure that that user is there and has sufficient rights.
0
 

Author Comment

by:kladtek
Comment Utility
thanks for your reply

having a look at the logins as u mentioned her is what i found

BUILTIN\Admisnitrator
NT AUTHORITY\SYSTEM
sa
TATA\SQLServer2005MSFTEUser$TATA$MSSQLSERVER

i guess the user is not there

what do i do next

thanks again
0
 
LVL 21

Expert Comment

by:naspinski
Comment Utility
you can add the user by right clicking 'Logins' and select 'New Login' now browse for the user and give them proper permissions in the 'server roles' tab.
0
 

Author Comment

by:kladtek
Comment Utility
hello thanks again

i successfully did that,

however, when i ran the script again it still gave me the same error message
0
 
LVL 21

Expert Comment

by:naspinski
Comment Utility
Is this on the same machine?
Do you have remote connections enabled?
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now