Showing posts with label aspx. Show all posts
Showing posts with label aspx. Show all posts

Monday, March 19, 2012

Assistance with Stored Procedure and ASPX Page Needed

Hello, I have the following stored procedure and the following aspx page. I am trying to connect this aspx page to the stored procedure using the SqlDataSource. When the user enters a branch number in textbox1, the autonumber generated by the database is returned in textbox2. I am not quite sure what to do to get this to execute. Can someone provide me assistance? Will I need to use some vb.net code behind?

Stored Procedure

CREATE PROCEDURE InsertNearMiss @.Branch Int, @.Identity int OUT ASINSERT INTO NearMiss (Branch)VALUES (@.Branch)

SET @.Identity = SCOPE_IDENTITY()

GO

ASPX Page

<asp:SqlDataSourceID="SqlDataSource1"runat="server"ConnectionString="<%$ ConnectionStrings:NearMissConnectionString%>" InsertCommand="InsertRecord"InsertCommandType="StoredProcedure"SelectCommand="InsertRecord" SelectCommandType="StoredProcedure"> <SelectParameters> <asp:ControlParameterControlID="TextBox1"Name="Branch"PropertyName="Text"Type="Int32"/> <asp:ControlParameterControlID="TextBox2"Direction="InputOutput"Name="Identity"PropertyName="Text"Type="Int32"/> </SelectParameters> <InsertParameters> <asp:ParameterName="Branch"Type="Int32"/> <asp:ParameterDirection="InputOutput"Name="Identity"Type="Int32"/> </InsertParameters> </asp:SqlDataSource> <asp:TextBoxID="TextBox1"runat="server"></asp:TextBox>

<asp:TextBoxID="TextBox2"runat="server"></asp:TextBox>

Here's all about getting the value of the most recently added record:http://www.mikesdotnetting.com/Article.aspx?ArticleID=54

SqlDataSource options are about 3/4 of the way down.

|||

It appears you are only doing an insert, so you can get rid of the whole <selectParameters> collection. In this case, I would create a handler for onInserted and have the handler insert the output value from the procedure into the textbox 2 box. To fire the event, put a button that has an onclick event handler that calls SqlDataSource1.Insert(). This fires the insert command of the datasource. Below is an example page and codebehind

12 id="testSource"3runat="server"4InsertCommand="usp_ins_test"5InsertCommandType="StoredProcedure"6ConnectionString='<%$ ConnectionStrings:test %>'7OnInserted="testSource_Inserted">89"TextBox1" Name="prm_b" Direction="Input" Type="int32" PropertyName="Text">10"prm_r" Direction="Output" Type="Int32">111213branch: "TextBox1" runat="server">
14returnedvalue: "TextBox2" runat="server">15"btnSubmit" runat="server" Text="Add New Branch" OnClick="btnSubmit_Click"/>
 Code Behind:
 
protected void btnSubmit_Click(object sender, EventArgs e) {if (Page.IsValid) { testSource.Insert(); } }protected void testSource_Inserted(object sender, SqlDataSourceStatusEventArgs e) {if (e.Exception !=null)//display an error message to the screen e.ExceptionHandled =true;else TextBox2.Text = e.Command.Parameters["@.prm_r"].Value.ToString(); }

That should do it.

--D

Saturday, February 25, 2012

aspx, mssql and datetime

Hi, i am trying to retrive some datetime set from the database (2 posts in this table), senastposted is a datetime field.
when i run:
SELECT senastposted FROM ftp WHERE senastposted <= 2005-10-28
i get this result:

senastposted
0 record(s) affected.


and when i run:
SELECT senastposted FROM ftp WHERE senastposted >= 2005-10-28
i get this result:

senastposted
25-10-2005
29-10-2005
2 record(s) affected.
what i want is to retrive the first value based on the date:
25-10-2005
any idea why SELECT senastposted FROM ftp WHERE senastposted <= 2005-10-28 dosent work?
( i have tried to change the dates to 28-10-2005 and 28/10-2005)

Hello Pafo,
You might try something similar to this:
<code>
SELECT DATE_FORMAT(datetime,'%d/%m/%Y') AS dt WHERE ...
</code>

|||you might want to actually ask a question here.
|||Please excuse the earlier comment. When i clicked the link the text of the message was a single period.
Most DBMS systems use proprietary extentions for dealing withdates. Stuff like 'before' or 'after'. look up dateoperations in SqlServer.

Aspx with IIS6 with SQL 2000

Hi All,
I am trying to run aspx website on IIS version 6. It works locally with WEb Matrix but when I put the site into the IIS server, it cannot connect to the database. THe IIS is sonfigured and all users have full permissions but the error that is returned is:
Login failed for user '(null)'. Reason: Not associated with a treusted SQL Server connection.
SQL Server 2000 is installed and a connection is open to the database in question.
Would be very greatfull for ANY help on this, being tryin to get this workin for days!!
Collette.
Hi,
I have explained the cause and resolution for this error in the following articles.
http://harishmvp.blogspot.com/2005/05/you-may-receive-error-login-failed-for.html
http://harishmvp.blogspot.com/2005/05/you-may-receive-error-login-failed-for_25.html
One of the above should help you.
Write back if this doesnt help.
Thanks.|||

Hi!

Still having problems with the this! Done everything in the two documents and still no joy!

Error: Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection
Please help!!

Collette.

|||

Hi,

Can you let me know your scenario?

Thanks.

aspx vb sql parameter passing

Hello,
Can someone kindly point out what is wrong with the following code file. I'm trying to:
- fill a dropdown from a db on page load (this works!)
- when user selects from the list and hits a button, pass the dropdown value to a second query
- use the second query to make another call to the db and fill a data grid

In the code below, if I swap an actual value (eg '1005') into the command and comment out the .Parameter.Add statements, the dategrid is filled sucessfully. Otherwise, when the button is pressed, nothing is displayed.

Thanks

PS comments about my coding approach are welcome - I'm new to aspx...


<%@. Language="VBScript" Debug="true"%>
<%@. Import Namespace="System.Data" %>
<%@. Import Namespace="System.data.SqlClient" %>
<html>
<head>
<script language="vb" runat="server">
Dim dbConnection As SqlConnection
Dim ds_Teams,ds_Agents As DataSet
Dim sqlCmd_Teams,sqlCmd_Agents As SqlDataAdapter

Dim dbConn = "server=csacd01;uid=mpierce;pwd=cabledog;database=clearviewacd"

Dim sql_select_teams = "" & _
"SELECT team_no, team_name " & _
"FROM dbo.team " & _
"WHERE (team_status = 'Curr')"

Dim sql_select_agents = "" & _
"SELECT last_name + ', ' + first_name AS name, agent_no " & _
"FROM dbo.users " & _
"WHERE (team_no = @.Team) AND (NOT (agent_no = '1029')) " & _
" AND (NOT (last_name IS NULL)) " & _
" AND (NOT (first_name IS NULL)) " & _
" AND (NOT (first_name = 'FirstName')) " & _
"ORDER BY last_name"

Dim teamList = "teamList"
Dim agentList = "agentList"

Sub Page_Load(Sender As Object, E As EventArgs)
if not (IsPostBack)
ds_Teams = new DataSet()
dbConnection = New SqlConnection(dbConn)
sqlCmd_Teams = New SqlDataAdapter(sql_select_teams, dbConnection)
sqlCmd_Teams.Fill(ds_Teams, teamList)
dbConnection.close()

dropdownlist_Teams.DataSource=ds_Teams.Tables(teamList).DefaultView
dropdownlist_Teams.DataBind()
end if
End Sub

sub Get_Agents(Sender As Object, E As EventArgs)
ds_Agents = new DataSet()
dbConnection = New SqlConnection(dbConn)
sqlCmd_Agents = new SqlDataAdapter(sql_select_agents, dbConnection)

sqlCmd_Agents.SelectCommand.Parameters.Add(new SqlParameter("@.Team", SqlDbType.NVarChar,4))
sqlCmd_Agents.SelectCommand.Parameters("@.Team").Value = dropdownlist_Teams.DataValueField

sqlCmd_Agents.Fill(ds_Agents,agentList)

dbConnection.close()

datagrid_Agents.DataSource=ds_Agents.Tables(agentList).DefaultView
datagrid_Agents.DataBind()
end sub

</script>
</head>
<body>
<form runat="server">
<asp:DropDownList id="dropdownlist_Teams" runat="server"
DataTextField="team_name"
DataValueField="team_no">
</asp:DropDownList
<input type="submit" onserverclick="Get_Agents" value="Get Agents" runat="server"><br /
<ASP:DataGrid id="datagrid_Agents" runat="server"
Width="500"
BackColor="#ccccff"
BorderColor="black"
ShowFooter="false"
CellPadding=3
CellSpacing="0"
Font-Name="Verdana"
Font-Size="8pt"
HeaderStyle-BackColor="#aaaadd"
EnableViewState="false"
/>
</form>
</body>
</html>

(1) dim a variable as string and then assign the sql stmt to the variable.
xample :
dim str1 as string
str1="Select..."

(2) is the valuefield numeric or string type ? also you might want to move the assigning of the str stmt to the get_events event itself rather than declaring it as a global string.

hth

AspX Page Connection Error using sqlserver

Dear i am using visual studio.net........ when i connect database (in sqlserver) using sqldataAdapter with datagrid in visual basic.net every thing work properly......... but when i use the same in asp.net then i get an error message on the resultant explorer page give below.

Server Error in '/studentData' Application.
------------------------

Login failed for user 'RAMIZSARDAR\ASPNET'.
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.SqlClient.SqlException: Login failed for user 'RAMIZSARDAR\ASPNET'.

Source Error:

Line 85: 'Put user code to initialize the page here
Line 86: Dim ds As New DataSet()
Line 87: SqlDataAdapter1.Fill(ds)
Line 88: DataGrid1.DataSource = ds.Tables(0)
Line 89: DataGrid1.DataBind()

Source File: c:\inetpub\wwwroot\studentData\WebForm1.aspx.vb Line: 87

Stack Trace:

[SqlException: Login failed for user 'RAMIZSARDAR\ASPNET'.]
System.Data.SqlClient.SqlConnection.Open()
System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState)
System.Data.Common.DbDataAdapter.Fill(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
studentData.WebForm1.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\studentData\WebForm1.aspx.vb:87
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()

------------------------
Version Information: Microsoft .NET Framework Version:1.0.3705.0; ASP.NET Version:1.0.3705.0

Plz solve my problem and Reply me on ramiz_ch@.hotmail.com
Plz solve my problem and Reply me on ramiz_ch@.hotmail.com
Plz solve my problem and Reply me on ramiz_ch@.hotmail.com

Ramizwell, yes. if you use the same code in VB.NET/WIndows forms it'll run under the security context of the currently logged-in user. i.e. YOU.

under ASP.NET it runs by default as the ASP.NET guest account, MACHINENAME\ASPNET

you need to add ASPNET to the SQL Server permissions list, OR run ASP.NET as a different user, OR specify a SQL Server auth account in your connection string.

this question has been covered over and over in these forums. try the FAQ, if it's not in there I'll be shocked and amazed.

aspx page and Reporting Service

Generally, when I type http://MyServer/Reports in the location, it takes me
to the home page. On that page I see a bar with "New Folder", "New Data
Souce", "Upload File" and "Show Details" options. Below that I see "Sales
Reports" and "SampleReports" folders. Clicking those links it takes us to
the list of reports.
How can I add a folder there called "Maintenance" (Where I see "Sales
Reports" and "SampleReports" folders i.e Home page). Clicking that link it
should list all Maintenance programs available (For Example, "ReasonCodes").
That link should take us to the aspx page.
Any Suggestions?It sounds like you're trying to mix aspx pages and report manager pages.
That's not really possible using the default Report Manager. You can either
build a custom report manager that replaces the user interface, or have a
separate "Maintenance" web virtual root.
You might be able to pull this off by simply creating a report that is
nothing but links to maintenance pages that sit outside of (next to)
Reporting Services.
So the URLs would look like this:
/Reports/Folder1
/Reports/Folder1/Report1
/Reports/Folder1/Report2
/Reports/Maintenance < report with links
etc.
/Maintenance/ReasonCodes.aspx < regular ASP.NET page in separate virtual
directory from reporting
Cheers,
--
'(' Jeff A. Stucker
\
Business Intelligence
www.criadvantage.com
---
"RA" <rchaudhary-nospam@.storis.com> wrote in message
news:%23RDhI$NzEHA.2624@.TK2MSFTNGP11.phx.gbl...
> Generally, when I type http://MyServer/Reports in the location, it takes
> me to the home page. On that page I see a bar with "New Folder", "New Data
> Souce", "Upload File" and "Show Details" options. Below that I see "Sales
> Reports" and "SampleReports" folders. Clicking those links it takes us to
> the list of reports.
> How can I add a folder there called "Maintenance" (Where I see "Sales
> Reports" and "SampleReports" folders i.e Home page). Clicking that link it
> should list all Maintenance programs available (For Example,
> "ReasonCodes"). That link should take us to the aspx page.
> Any Suggestions?
>|||Unfortunately, the list of reports or main view of Reporting Services is not
customizable. What you see is what you get. As you add more objects,
reports, folders, files, etc. Reporting Services will manage the list & menu
choices for you.
"RA" wrote:
> Generally, when I type http://MyServer/Reports in the location, it takes me
> to the home page. On that page I see a bar with "New Folder", "New Data
> Souce", "Upload File" and "Show Details" options. Below that I see "Sales
> Reports" and "SampleReports" folders. Clicking those links it takes us to
> the list of reports.
> How can I add a folder there called "Maintenance" (Where I see "Sales
> Reports" and "SampleReports" folders i.e Home page). Clicking that link it
> should list all Maintenance programs available (For Example, "ReasonCodes").
> That link should take us to the aspx page.
> Any Suggestions?
>
>

Aspx fashion tip... ;)

Hi!

Im building a site for internal use for a company i work at.
And im having hard to decide what to do. The alternatives are

comma separated lists vs separate tables.

For example.. I will use a number of different type of objekt that all will hold 1 or more document links, phone numbers, emails etc

As far as i can i i have 2 possibilitys. One is to add textfields for each of these subojects in each objects tables. Then i add all info as commaseparrated lists in 2-3 layers wich i then save in the respecive objects fields.
(Look like something below for example )
,comment'emailadress,comment'emailadress,

Or i add 1 table for each subobject type wich manage the subobjects or link between different objects
for example:
table layout for email:
id | parent_type | parent_id | comment | email

Or for example contacts a mediator table:
id | parent_type | parent_id | contact_id

Hope you understand what i mean, would really appriechiate suggestions, comments regarding what can be considered as "best practise" in these cases. Putting it in separate tables should make searches easier, and coding easier in my book. But again im thinking if perhaps commalists is a faster and more recource conservative way of doing it + to me it feels like (perhaps i have no reason to think this?) making tables for items like feels like a timebomb if you exhaust your idfields identity count. Though this app will be used by perhaps 100ppl at most so perhaps not an extremely utilized webapp.

Anyway glad if you could give me some input!

I prefer seperate tables, as this gives clearer description of data structure/relationship, and it is much easier to manipulate the data in seperate tables.|||

Yeah well separate tables sure is the easiest way to get around it considering searches, changes when built etc.

Practically for me it will mean perhaps 3-5 querys in one page instead 1-2. So that is the main drawback i guess wich perhaps wont inflict to much.

Anyway my main concern was if there was anything that motivated commalists or its just a small gain for quite a bit more work in creating/changing.

|||

"if you exhaust your idfields identity count"? If you were inserting a new record once every second non-stop, it'd take over 68 years to exceed the limits of an int. And when you get there, consider upgrading to SQL Server 2050 which solves that problem automatically for you. But if you think there is the possability that your app will need to run for 68+ years without a change, or if your think you'll need to insert more than 86,000 rows per day, then you might consider a bigint.

|||

Yeah did som calculations and came to the same conclusion ;)

Anyway think i will go for tables, for convineance sake.

ASPNETDB.MDF?

Using VS2005, VB backend and javascript,

I have developed a relatively simple site - its got a few (12) simple aspx pages but its mostly client side javascript. Keeping disk storage costs down is a big concern with this my site. The disk usage for the site is ~24M. Since this was larger than I expected I started inspecting the files comprising my site and found that the "ASPNETDB.MDF" in my "App_data" folder is consuming 10.2M by itself. The thing is that site only has a few pages with calls to SQL Server - but I never did anything (that I know of) with ASPNETDB.MDF. Through VS2005, I opened up the MDF file and poked around, everything that I looked at was empty (NULL).

So my questions are:

What is causing the ASPNETDB.MDF to consume 10.2M even thought I can't see any data stored in it?Is there anyway for my to reduce the size of this file? If so, how?

Your input appreciated.

Should I be posting this in a different forum?|||

Hi,

The ASPNETDB contains a lot of information about table structure and membership information about your site.

To check what is occupying the storage, you can run DBCC CHECKDB on your local machine to see the allocation, structural, and logical integrity of all the objects in the specified database.

For more information, please check the following link.

http://msdn2.microsoft.com/en-us/library/aa258278(SQL.80).aspx

HTH. If this does not answer you question, please feel free to mark it as Not Answered and post your reply. Thanks!

ASPNETDB.mdf Resolved

Hi,

I thought I had this corrected, but in fact don't. According to http://msdn2.microsoft.com/en-us/library/ms228037.aspx

SQL Express is supposed to automatically generate a copy of ASPNETDB.mdf in the App_Data folder of the Express edition development suites (I'm using Visual Web Developer 2005).

In my case, it doesn't, and I can't figure out how to trigger it manually. I've read every post I can find, especially http://forums.microsoft.com/msdn/showpost.aspx?postid=98346&siteid=1

However, that mainly applies to deploying a database that already exists. I have already tried deleting the files as suggested and they do reappear in the appropriate folder, but I'm still not getting the ASPNETDB.mdf file in my apps.

Any help on this would be greatly appreciated. I've had a post up on the Visual Web Developer forum, but folk are staying away in droves. Also tried uninstall and reinstall all the way down to IIS 5.1

biobot

You install the database by executing Aspnet_regsql.exe
in your %windir%\Microsoft.NET\Framework\<Your.Net Framework version> folder

You can find installation instructions and other information in the following article:

How To: Use Role Manager in ASP.Net 2.0

http://msdn2.microsoft.com/en-us/library/ms998314.aspx

-Sue

|||

Sue,

Thank you! It took some improvising, but I am now getting the aspnetdb.mdf auto-generating as is should. (There are some differences between the SQLEXPRESS Management Suite and Enterprise Manager, apparently).

I never would have thought to look up how to use Role manager to solve this problem!!?

Also, it is great to get a response in complete, contextually relevant sentences!

Best regards,

Larry

|||Open Visual Web Developer Express (VWD). Open the website in VWD. Click on the 'Website' menu. At the bottom of the website menu is ASP.Net configuration, open it. It opens ‘Asp.Net Website Administration Tool’. Under the 'Security' tab add a user.

Done; ASPNETDB.mdf is up and configured for your website|||Doesn't work in a shared environment

Friday, February 24, 2012

ASPNETDB.mdf

Hi,

I thought I had this corrected, but in fact don't. According to http://msdn2.microsoft.com/en-us/library/ms228037.aspx

SQL Express is supposed to automatically generate a copy of ASPNETDB.mdf in the App_Data folder of the Express edition development suites (I'm using Visual Web Developer 2005).

In my case, it doesn't, and I can't figure out how to trigger it manually. I've read every post I can find, especially http://forums.microsoft.com/msdn/showpost.aspx?postid=98346&siteid=1

However, that mainly applies to deploying a database that already exists. I have already tried deleting the files as suggested and they do reappear in the appropriate folder, but I'm still not getting the ASPNETDB.mdf file in my apps.

Any help on this would be greatly appreciated. I've had a post up on the Visual Web Developer forum, but folk are staying away in droves. Also tried uninstall and reinstall all the way down to IIS 5.1

biobot

You install the database by executing Aspnet_regsql.exe
in your %windir%\Microsoft.NET\Framework\<Your.Net Framework version> folder

You can find installation instructions and other information in the following article:

How To: Use Role Manager in ASP.Net 2.0

http://msdn2.microsoft.com/en-us/library/ms998314.aspx

-Sue

|||

Sue,

Thank you! It took some improvising, but I am now getting the aspnetdb.mdf auto-generating as is should. (There are some differences between the SQLEXPRESS Management Suite and Enterprise Manager, apparently).

I never would have thought to look up how to use Role manager to solve this problem!!?

Also, it is great to get a response in complete, contextually relevant sentences!

Best regards,

Larry

Sunday, February 19, 2012

ASPNET account can't connect to MSSQLSERVER

When I try to access my PasswordRecovery.aspx page I get an error. I've also added the Event Warning and the Failure Audit. I've tried deleting the ASPNET user account and recreating it using aspnet_regiis.exe. I still get the same error message. Should I add the ASPNET account to the Administrators group? Currently it is with the Users group.

Login failed for user 'PC325862970629\ASPNET'.

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.SqlClient.SqlException: Login failed for user 'PC325862970629\ASPNET'.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace:

[SqlException (0x80131904): Login failed for user 'PC325862970629\ASPNET'.]

System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +734979

System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188

System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1838

System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +33

System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +628

System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +170

System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +359

System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +28

System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +424

System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66

System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +496

System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +82

System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +105

System.Data.SqlClient.SqlConnection.Open() +111

System.Web.DataAccess.SqlConnectionHolder.Open(HttpContext context, Boolean revertImpersonate) +84

System.Web.DataAccess.SqlConnectionHelper.GetConnection(String connectionString, Boolean revertImpersonation) +197

System.Web.Security.SqlMembershipProvider.GetPasswordWithFormat(String username, Boolean updateLastLoginActivityDate, Int32& status, String& password, Int32& passwordFormat, String& passwordSalt, Int32& failedPasswordAttemptCount, Int32& failedPasswordAnswerAttemptCount, Boolean& isApproved, DateTime& lastLoginDate, DateTime& lastActivityDate) +1121

System.Web.Security.SqlMembershipProvider.CheckPassword(String username, String password, Boolean updateLastLoginActivityDate, Boolean failIfNotApproved, String& salt, Int32& passwordFormat) +105

System.Web.Security.SqlMembershipProvider.CheckPassword(String username, String password, Boolean updateLastLoginActivityDate, Boolean failIfNotApproved) +42

System.Web.Security.SqlMembershipProvider.ValidateUser(String username, String password) +83

System.Web.UI.WebControls.Login.OnAuthenticate(AuthenticateEventArgs e) +160

System.Web.UI.WebControls.Login.AttemptLogin() +105

System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e) +99

System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35

System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +115

System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +163

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7

System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11

System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33

System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102

When I check my Events log I see this warning:

-

Event Type: Warning
Event Source: ASP.NET 2.0.50727.0
Event Category: Web Event
Event ID: 1309
Date: 8/24/2006
Time: 5:13:54 PM
User: N/A
Computer: PC325862970629
Description:
Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 8/24/2006 5:13:54 PM
Event time (UTC): 8/25/2006 12:13:54 AM
Event ID: b3b1e4fbbd634d04a5acd3de09a4df88
Event sequence: 22
Event occurrence: 7
Event detail code: 0
Application information:
Application domain: /LM/W3SVC/1/Root/Aidms-1-128009374139687500
Trust level: Full
Application Virtual Path: /Aidms
Application Path: C:\aidms\
Machine name: PC325862970629
Process information:
Process ID: 5128
Process name: aspnet_wp.exe
Account name: PC325862970629\ASPNET
Exception information:
Exception type: SqlException
Exception message: Login failed for user 'PC325862970629\ASPNET'.
Request information:
Request URL: http://localhost/Aidms/Default.aspx
Request path: /Aidms/Default.aspx
User host address: 127.0.0.1
User:
Is authenticated: False
Authentication Type:
Thread account name: PC325862970629\ASPNET
Thread information:
Thread ID: 1
Thread account name: PC325862970629\ASPNET
Is impersonating: False
Stack trace: at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK)
at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at System.Web.DataAccess.SqlConnectionHolder.Open(HttpContext context, Boolean revertImpersonate)
at System.Web.DataAccess.SqlConnectionHelper.GetConnection(String connectionString, Boolean revertImpersonation)
at System.Web.Security.SqlMembershipProvider.GetPasswordWithFormat(String username, Boolean updateLastLoginActivityDate, Int32& status, String& password, Int32& passwordFormat, String& passwordSalt, Int32& failedPasswordAttemptCount, Int32& failedPasswordAnswerAttemptCount, Boolean& isApproved, DateTime& lastLoginDate, DateTime& lastActivityDate)
at System.Web.Security.SqlMembershipProvider.CheckPassword(String username, String password, Boolean updateLastLoginActivityDate, Boolean failIfNotApproved, String& salt, Int32& passwordFormat)
at System.Web.Security.SqlMembershipProvider.CheckPassword(String username, String password, Boolean updateLastLoginActivityDate, Boolean failIfNotApproved)
at System.Web.Security.SqlMembershipProvider.ValidateUser(String username, String password)
at System.Web.UI.WebControls.Login.OnAuthenticate(AuthenticateEventArgs e)
at System.Web.UI.WebControls.Login.AttemptLogin()
at System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e)
at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
at System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Custom event details:

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

And then I see this Failutre Audit

--

Event Type: Failure Audit
Event Source: MSSQLSERVER
Event Category: (4)
Event ID: 18456
Date: 8/24/2006
Time: 5:13:54 PM
User: PC325862970629\ASPNET
Computer: PC325862970629
Description:
Login failed for user 'PC325862970629\ASPNET'. [CLIENT: <local machine>]

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
Data:
0000: 18 48 00 00 0e 00 00 00 .H......
0008: 0f 00 00 00 50 00 43 00 ....P.C.
0010: 33 00 32 00 35 00 38 00 3.2.5.8.
0018: 36 00 32 00 39 00 37 00 6.2.9.7.
0020: 30 00 36 00 32 00 39 00 0.6.2.9.
0028: 00 00 07 00 00 00 6d 00 ......m.
0030: 61 00 73 00 74 00 65 00 a.s.t.e.
0038: 72 00 00 00 r...

The security folks may be able to answer this more quickly.

Thanks,
Sam

|||Is your ASP.NET app and SQL Server both in the same machine?|||Yes both ASP and SQLSERVRER are running on the same machine.|||

Can you have a look at the errorlog file of SQL Server and copy the error logged there? It should be under the LOG directory of your installation. A new log is created after each restart, so you may have to look at several files to find the one that contains this error.

Also, have you allowed the ASPNET account to access your SQL Server installation? Did this connection ever work or is it the first time you tried it?

Thanks
Laurentiu

|||I didn't have to allow the ASNET account access to my SQL Server installation before because it was working fine. Can you please give me the instructions to allow access to my SQL server?

Below is the log file from SQL server that I believe ties in to the above problem.
-
2006-08-24 16:55:27.06 Server Microsoft SQL Server 2005 - 9.00.1399.06 (Intel X86)
Oct 14 2005 00:33:37
Copyright (c) 1988-2005 Microsoft Corporation
Standard Edition on Windows NT 5.1 (Build 2600: Service Pack 2)

2006-08-24 16:55:27.06 Server (c) 2005 Microsoft Corporation.
2006-08-24 16:55:27.06 Server All rights reserved.
2006-08-24 16:55:27.06 Server Server process ID is 2636.
2006-08-24 16:55:27.06 Server Logging SQL Server messages in file 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\ERRORLOG'.
2006-08-24 16:55:27.06 Server This instance of SQL Server last reported using a process ID of 476 at 8/24/2006 4:53:33 PM (local) 8/24/2006 11:53:33 PM (UTC). This is an informational message only; no user action is required.
2006-08-24 16:55:28.46 Server Registry startup parameters:
2006-08-24 16:55:28.54 Server -d C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\master.mdf
2006-08-24 16:55:28.54 Server -e C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\ERRORLOG
2006-08-24 16:55:28.54 Server -l C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\mastlog.ldf
2006-08-24 16:55:29.46 Server SQL Server is starting at normal priority base (=7). This is an informational message only. No user action is required.
2006-08-24 16:55:29.46 Server Detected 1 CPUs. This is an informational message; no user action is required.
2006-08-24 16:55:33.07 Server Using dynamic lock allocation. Initial allocation of 2500 Lock blocks and 5000 Lock Owner blocks per node. This is an informational message only. No user action is required.
2006-08-24 16:55:35.20 Server Attempting to initialize Microsoft Distributed Transaction Coordinator (MS DTC). This is an informational message only. No user action is required.
2006-08-24 16:55:37.06 Server The Microsoft Distributed Transaction Coordinator (MS DTC) service could not be contacted. If you would like distributed transaction functionality, please start this service.
2006-08-24 16:55:37.15 Server Database Mirroring Transport is disabled in the endpoint configuration.
2006-08-24 16:55:37.37 spid5s Starting up database 'master'.
2006-08-24 16:55:37.82 spid5s Recovery is writing a checkpoint in database 'master' (1). This is an informational message only. No user action is required.
2006-08-24 16:55:38.37 spid5s SQL Trace ID 1 was started by login "sa".
2006-08-24 16:55:38.46 spid5s Starting up database 'mssqlsystemresource'.
2006-08-24 16:55:38.92 spid9s Starting up database 'model'.
2006-08-24 16:55:38.93 spid5s Server name is 'PC325862970629'. This is an informational message only. No user action is required.
2006-08-24 16:55:39.26 Server A self-generated certificate was successfully loaded for encryption.
2006-08-24 16:55:39.28 Server Server is listening on [ 'any' <ipv4> 1433].
2006-08-24 16:55:39.28 Server Server local connection provider is ready to accept connection on [ \\.\pipe\SQLLocal\MSSQLSERVER ].
2006-08-24 16:55:39.28 Server Server named pipe provider is ready to accept connection on [ \\.\pipe\sql\query ].
2006-08-24 16:55:39.28 Server Server is listening on [ 127.0.0.1 <ipv4> 1434].
2006-08-24 16:55:39.28 Server Dedicated admin connection support was established for listening locally on port 1434.
2006-08-24 16:55:39.32 Server The SQL Network Interface library could not register the Service Principal Name (SPN) for the SQL Server service. Error: 0x54b. Failure to register an SPN may cause integrated authentication to fall back to NTLM instead of Kerberos. This is an informational message. Further action is only required if Kerberos authentication is required by authentication policies.
2006-08-24 16:55:39.34 Server SQL Server is now ready for client connections. This is an informational message; no user action is required.
2006-08-24 16:55:39.87 spid9s Clearing tempdb database.
2006-08-24 16:55:41.20 spid9s Starting up database 'tempdb'.
2006-08-24 16:55:42.79 spid12s The Service Broker protocol transport is disabled or not configured.
2006-08-24 16:55:42.79 spid12s The Database Mirroring protocol transport is disabled or not configured.
2006-08-24 16:55:42.92 spid12s Service Broker manager has started.
2006-08-24 16:55:45.23 spid14s Starting up database 'msdb'.
2006-08-24 16:55:45.23 spid16s Starting up database 'Aidms'.
2006-08-24 16:55:48.67 spid5s Recovery is complete. This is an informational message only. No user action is required.
2006-08-24 16:57:16.43 Logon Error: 18456, Severity: 14, State: 11.
2006-08-24 16:57:16.43 Logon Login failed for user 'PC325862970629\ASPNET'. [CLIENT: <local machine>]
2006-08-24 16:57:31.57 Logon Error: 18456, Severity: 14, State: 11.
2006-08-24 16:57:31.57 Logon Login failed for user 'PC325862970629\ASPNET'. [CLIENT: <local machine>]
2006-08-24 16:58:41.96 Logon Error: 18456, Severity: 14, State: 11.
2006-08-24 16:58:41.96 Logon Login failed for user 'PC325862970629\ASPNET'. [CLIENT: <local machine>]
2006-08-24 17:06:49.76 Logon Error: 18456, Severity: 14, State: 11.
2006-08-24 17:06:49.76 Logon Login failed for user 'PC325862970629\ASPNET'. [CLIENT: <local machine>]
2006-08-24 17:09:40.25 Logon Error: 18456, Severity: 14, State: 11.
2006-08-24 17:09:40.25 Logon Login failed for user 'PC325862970629\ASPNET'. [CLIENT: <local machine>]
2006-08-24 17:13:54.57 Logon Error: 18456, Severity: 14, State: 11.
2006-08-24 17:13:54.57 Logon Login failed for user 'PC325862970629\ASPNET'. [CLIENT: <local machine>]
2006-08-24 17:23:59.60 Logon Error: 18456, Severity: 14, State: 11.
2006-08-24 17:23:59.60 Logon Login failed for user 'PC325862970629\ASPNET'. [CLIENT: <local machine>]
2006-08-24 17:36:26.00 Server SQL Server is terminating because of a system shutdown. This is an informational message only. No user action is required.
2006-08-24 17:36:28.03 spid12s Service Broker manager has shut down.
2006-08-24 17:36:28.04 spid12s Error: 17054, Severity: 16, State: 1.
2006-08-24 17:36:28.04 spid12s The current event was not reported to the Windows Events log. Operating system error = 31(A device attached to the system is not functioning.). You may need to clear the Windows Events log if it is full.
2006-08-24 17:36:31.17 spid5s SQL Trace was stopped due to server shutdown. Trace ID = '1'. This is an informational message only; no user action is required.
2006-08-24 17:36:33.01 Server The SQL Network Interface library could not deregister the Service Principal Name (SPN) for the SQL Server service. Error: 0x54b. Administrator should deregister this SPN manually to avoid client authentication errors.|||

You can execute:

CREATE LOGIN [PC325862970629\ASPNET] FROM WINDOWS

to create a SQL login for the ASPNET account. Let us know if this doesn't solve the login failure. I am not sure about the additional permissions that you need to grant to the ASPNET account for your application to work. A better forum for such further inquiries would be the ASP.Net forum at: http://forums.asp.net/default.aspx.

Thanks
Laurentiu

|||Aspnet_regiis.exe creates the ASPNET account for windows. I've deleted and recreated the account twice but I still get the same above error. Any help from a Microsoft representative would help in addition to the suggestions that have been given to far.|||

The command I mentioned in my previous post needs to be executed within SQL Server. You need to connect to SQL Server using a tool like sqlcmd or Management Studio, and issue that command to allow the ASPNET account to connect to SQL Server.

Thanks
Laurentiu

|||Thank you very much. Your previous post was te solution to my problem.

Sunday, February 12, 2012

ASP.NET connection string problems with SQL Server 2000

My aspx page is trying to connect to a remote server with SQL Server 2000 installed on it, the ip of the server is 172.16.3.111 and the same is the instance of SQL Server, sql server is running in SQL Server Authentication mode, user id is "test" and password is "test123", name of database is myDB,the connection string which I am providing is as follows:

data source=172.16.3.111\172.16.3.111;user id=test;password=test123;initial catalog=myDB;"

But I am getting the following exception:

SQL Server does not exist or access denied.

even if I try the following connection string:
"data source=172.16.3.111;user id=test;password=test123;initial catalog=myDB;"

than also I get the same exception

even if provide the following connection strings:

"SERVER=172.16.3.111;UID=test;PWD=test123;DATABASE =myDB;"

"SERVER=172.16.3.111\172.16.3.111;UID=test;PWD=test123;DATABASE =myDB;"

than also I get the same exceptions

Can u please tell whats the problem,is the connection string correct,the DBA has also registered me "test" as a user on the SQL server.One thing which I want to mention is that through enterprise manager I can connect and use sql server without any problems,also please note that in VS.NET when I try connecting using server explorer and test the connection than I connect successfully, than why is problem occuring in connecting throug aspx page.

Try change the param "Server" like this:

\\ server name or server ip \ instance name

Thursday, February 9, 2012

ASP.NET * Cannot find file

When launching created file 'eSurvey.aspx' the following error occurs.
How can I resolve this matter? Thanks!
ERROR:
Could not find a part of the path "E:\Documents and
Settings\wardte\Desktop\eSurvey\convert\
files\Rigid_PCB_Questionnaire.htm".
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information abou
t
the error and where it originated in the code.
Exception Details: System.IO.DirectoryNotFoundException: Could not find a
part of the path "E:\Documents and
Settings\wardte\Desktop\eSurvey\convert\
files\Rigid_PCB_Questionnaire.htm".
Source Error:
Line 107: objStreamReader = File.OpenText(filename)You are posting in the wrong forum. This is a SQL server forum, and you
have an ASP.Net issue.
The error you are recieving told you exactly what the problem is, the file
the code is trying to access cannot be found. Either the files doesnt
exist, the path is wrong, or the user for which the code is running does not
have access to the file.
You are going to have to look through the ASPX and the .Net source code and
determine where the code is trying to access the file, but the first thing
you need to do is look on the server for :
"E:\Documents and
Settings\wardte\Desktop\eSurvey\convert\
files\Rigid_PCB_Questionnaire.htm"
Make sure you do this on the server, and not on the client PC (unless the PC
is the web server).
Keep in mind that the drive mapping may not exist for the user under which
the web server code is running. Using the \\ServerName\ShareName\FilePath
instead of referring to the E:\ drive may also fix your problem.
The ASP.Net user groups will provide much more help than you will get here.
They can also point you in the direction of some ASP.Net and file access
tutorials that will help you to make more sense of the code.
Good luck!
"Terry" <Terry@.discussions.microsoft.com> wrote in message
news:688AE5DE-A9F0-429C-8BE3-56871AEEDE73@.microsoft.com...
> When launching created file 'eSurvey.aspx' the following error occurs.
> How can I resolve this matter? Thanks!
> ERROR:
> Could not find a part of the path "E:\Documents and
>
Settings\wardte\Desktop\eSurvey\convert\
files\Rigid_PCB_Questionnaire.htm".
> 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.IO.DirectoryNotFoundException: Could not find a
> part of the path "E:\Documents and
>
Settings\wardte\Desktop\eSurvey\convert\
files\Rigid_PCB_Questionnaire.htm".
> Source Error:
> Line 107: objStreamReader = File.OpenText(filename)
>

ASP.NET - File not found error * Pls. help!

When launching created file 'eSurvey.aspx' the following error occurs.
How can I resolve this matter? Thanks!
ERROR:
Could not find a part of the path "E:\Documents and
Settings\wardte\Desktop\eSurvey\convert\files\Rigid_PCB_Questionnaire.htm".
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.IO.DirectoryNotFoundException: Could not find a
part of the path "E:\Documents and
Settings\wardte\Desktop\eSurvey\convert\files\Rigid_PCB_Questionnaire.htm".
Source Error:
Line 107: objStreamReader = File.OpenText(filename)When running the the .ASPX file via Visual Studio, the .ASPX file works fine.
Why?
"Terry" wrote:
> When launching created file 'eSurvey.aspx' the following error occurs.
> How can I resolve this matter? Thanks!
> ERROR:
> Could not find a part of the path "E:\Documents and
> Settings\wardte\Desktop\eSurvey\convert\files\Rigid_PCB_Questionnaire.htm".
> 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.IO.DirectoryNotFoundException: Could not find a
> part of the path "E:\Documents and
> Settings\wardte\Desktop\eSurvey\convert\files\Rigid_PCB_Questionnaire.htm".
> Source Error:
> Line 107: objStreamReader = File.OpenText(filename)
>