Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 23rd, 2004, 10:49 AM
Registered User
 
Join Date: Aug 2004
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Security Error Using DSN Connection

I apologize if this is in the wrong forum, I was not sure if it should go here since i am a beginner, or in the asp databases forum, but i did not want to post it in two forums.

I wrote an asp.net page, and have an access database. I was told by my web hoster that i need to use create a DSN connection, and give write rights to the database, all of which i did. however when i try to write to the database, i get the following error

System.Security.SecurityException: Request failed

the stack trace is

[SecurityException: Request failed.]
ASP.What_aspx.InsertReviewAccess(String initials, String Opinion) +0
ASP.What_aspx.Button1_Click(Object sender, EventArgs e) +74
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
System.Web.UI.Page.ProcessRequestMain() +2106
System.Web.UI.Page.ProcessRequest() +218
System.Web.UI.Page.ProcessRequest(HttpContext context) +18
System.Web.CallHandlerExecutionStep.System.Web.Htt pApplication+IExecutionStep.Execute() +179
System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean& completedSynchronously) +87

My code to connect to the Database is

Function InsertReviewAccess(Byval initials as string, ByVal Opinion as string) As Integer

'Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source= ../db/AccessforWebMatrix.mdb"
'Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString )

dim DSN, OBJdbConnection
DSN = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.Mappath("../db/AccessforWebMatrix.mdb") & ";"
OBJdbConnection = Server.CreateObject("ADODB.Connection")
OBJdbConnection.Open(DSN)

Dim queryString As String = "INSERT INTO [WhatPPLAreSaying] ([Initials], [Opinion]) VALUES (@initials, @opinion)"
Dim dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = OBJdbConnection


Dim dbParam_initials As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
dbParam_initials.ParameterName = "@initials"
dbParam_initials.Value = initials
dbParam_initials.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_initials)


Dim dbParam_opinion As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
dbParam_opinion.ParameterName = "@opinion"
dbParam_opinion.Value = opinion
dbParam_opinion.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_opinion)

Dim rowsAffected As Integer = 0
OBJdbConnection.Open
Try
rowsAffected = dbCommand.ExecuteNonQuery
Finally
OBJdbConnection.Close
End Try

Return rowsAffected
End Function


before i created the DSN connection, it worked fine. The webhoster said that i had a scripting error.

the page can be viewed at "http://whyarentumarried.com/what.aspx"

any hellp would be great, thanks
  #2 (permalink)  
Old August 23rd, 2004, 11:31 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

I don't know if server.mappath likes ../. In addition, I don't know if Server.MapPath returns the folder path where you think it does. Try writing out the path and verify it to make sure that is correct.

Brian
  #3 (permalink)  
Old August 23rd, 2004, 12:43 PM
Registered User
 
Join Date: Aug 2004
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I tried using the full path
server.mappath("E:\kunden\homepages\36\d107504546\ db\accessforWebMatrix.mdb")
however i still get a security error that the request failed
  #4 (permalink)  
Old August 23rd, 2004, 02:51 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

Is this database on a separate server than the current one that the application belongs to?

Brian
  #5 (permalink)  
Old August 24th, 2004, 06:00 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

For Server.MapPath() you got to give the virtual path reference, which inturn gives you the full path. I don't remember if you can use the full path in server.mappath(), so if you are using full path remove server.mappath from there.

_________________________
- Vijay G
Strive for Perfection
  #6 (permalink)  
Old August 24th, 2004, 07:15 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

Vijay is right; do a Response.Write(server.mappath("E:\kunden\homepages \36\d107504546\db\accessforWebMatrix.mdb"))

to see the path, and correct as needed.

Brian
  #7 (permalink)  
Old August 24th, 2004, 08:38 AM
Registered User
 
Join Date: Aug 2004
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, for all your help
  #8 (permalink)  
Old August 24th, 2004, 09:30 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Did you find a solution?
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ODBC DSN connection atoyot BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 2 December 14th, 2006 06:40 PM
DSN Connection mred2nice Visual Studio 2005 0 October 31st, 2006 11:58 AM
How make an automatic dsn less connection abhisheksud Classic ASP Databases 3 October 7th, 2005 04:51 AM
DSN Connection problem patwadd Classic ASP Basics 4 February 9th, 2005 04:26 AM
dsn-less connection problem Justine SQL Server ASP 3 March 8th, 2004 01:45 PM



All times are GMT -4. The time now is 07:51 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.