 |
|
|
 |
|
 |
Hi all
I am trying to create a login page using ASP.NET and c# 2003 code behind. I am using Access database but i keep on getting this error when trying to connect to my database: Can someone please help me eliminate this error.
[Server Error in '/BookFlight' Application. --------------------------------------------------------------------------------
The Microsoft Jet database engine cannot open the file 'C:\Inetpub\wwwroot\FlightBooking.mdb'. It is already opened exclusively by another user, or you need permission to view its data. 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: The Microsoft Jet database engine cannot open the file 'C:\Inetpub\wwwroot\FlightBooking.mdb'. It is already opened exclusively by another user, or you need permission to view its data.
Source Error:
Line 159: Line 160: if(oleDbConnection1.State == ConnectionState.Closed) Line 161: oleDbConnection1.Open(); Line 162: Line 163: //while (dataReader.Read())
Source File: c:\inetpub\wwwroot\bookflight\login.aspx.cs Line: 161
Stack Trace:
[OleDbException (0x80004005): The Microsoft Jet database engine cannot open the file 'C:\Inetpub\wwwroot\FlightBooking.mdb'. It is already opened exclusively by another user, or you need permission to view its data.] System.Data.OleDb.OleDbConnection.ProcessResults(Int32 hr) System.Data.OleDb.OleDbConnection.InitializeProvider() System.Data.OleDb.OleDbConnection.Open() BookFlight.WebForm1.CustomValidator1_ServerValidate(Object source, ServerValidateEventArgs args) in c:\inetpub\wwwroot\bookflight\login.aspx.cs:161 System.Web.UI.WebControls.CustomValidator.OnServerValidate(String value) System.Web.UI.WebControls.CustomValidator.EvaluateIsValid() System.Web.UI.WebControls.BaseValidator.Validate() System.Web.UI.Page.Validate() System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) System.Web.UI.Page.ProcessRequestMain()
-------------------------------------------------------------------------------- Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032 ]
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Protected Sub btnlogin_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Login.Click
Dim stafid As String stafid = CStr(StaffNo.Text)
Dim dt As New Data.DataTable() Dim connstr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=your dbase dir" Dim sqlstr As String = "SELECT * from Staff" Dim dataAdapter As New Data.OleDb.OleDbDataAdapter(sqlstr, connstr)
dataAdapter.Fill(dt) dataAdapter.Dispose()
For i As Integer = 0 To (dt.Rows.Count - 1) If CStr(dt.Rows(i)("staff_no")) = stafid Then FileUpload1.Visible() = True btnUpload.Visible() = True Session("logged") = True Login.Visible() = False StaffNo.Visible() = False label1.Visible() = False
Else MsgBox("fail to log you in!", 0, "Login fail!!") End If Next End Sub
if error occur it might be this.. Dim dt As New Data.DataTable() change to Dim dt As New DataTable(), Dim dataAdapter As New Data.OleDb.OleDbDataAdapter(sqlstr, connstr) change to Dim dataAdapter As New OleDb.OleDbDataAdapter(sqlstr, connstr). im using vb2.0,but still the same although using c#.jana
|
| Sign In·View Thread·PermaLink | 1.67/5 |
|
|
|
 |
 | Help  asifahaniff | 6:38 20 Aug '06 |
|
 |
Syntax error in INSERT INTO statement. 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: Syntax error in INSERT INTO statement.
Source Error:
Line 33: Dim cmd as New OleDBCommand (MySQL, MyConn) Line 34: MyConn.Open () Line 35: cmd.ExecuteNonQuery () Line 36: MyConn.Close () Line 37:
Source File: D:\HCCRootWeb\AsifaTest\allahpleasework.aspx Line: 35
Stack Trace:
[OleDbException (0x80040e14): Syntax error in INSERT INTO statement.] System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr) +41 System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) +174 System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) +92 System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) +65 System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +112 System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +66 ASP.allahpleasework_aspx.OnBtnSendClicked(Object s, EventArgs e) in D:\HCCRootWeb\AsifaTest\allahpleasework.aspx:35 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33 System.Web.UI.Page.ProcessRequestMain() +1292
I keep getting this error on the line cmd.ExecuteNonQuery () Please if any one has any idea what is it regarding that will e a great help.
Thank you
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I'm able to use the entry page but the log view page just has the title with no records displayed and no errors. Any ideas why?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hello
Well Usually the IIS run the index.htm at first and that’s the page where you can write in guestbook which is “guestbook.aspx” and list all guestbook which is “guestlog.aspx” so type after the link index.htm ex: http://localhost/guestbook/index.htm or in Default Content page in IIS change the priorities so that index.htm will read first.
I hope I could help
Gabriel
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi How can i limit the numbers of the messages in the page, i mean after 10 messages will bw shown in the bottom of the page - next page or 1,2,3-> something like that. Thank's.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Nicely done!
I would like to point out a security issue in your code as it stands: SQL code injection.
In a nutshell: because you are building your SQL statement by hand (not using a stored procedure), and you are pasting the contents of the form controls straight into your SQL statement, you are leaving an opening for a malicious guest to run arbitrary SQL code on your database.
A short discussion can be found on CP here[^]. MSDN also did a Webcast[^] on the subject.
Jeffrey
Everything should be as simple as possible, but not simpler. -- Albert Einstein http://www.extremeoptimization.com/
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Using stored procedures won't completely stop SQL code injection.. What's to stop a user from entering sql statements inside the "message" input textbox. The sp is passed some parameters which it uses to build a SQL insert statement to insert a new row in the guestbook... Why can't a user close off the insert statement and than embedd an update or delete statement into the sp .. As long as the sp string is properly formated, than the sql statement(s) will be excuted...
Only proper user input parsing and filtering will solve the security risks you mention.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Tony Truong wrote: Using stored procedures won't completely stop SQL code injection.
This is true. If the stored procedure itself builds a query string that uses the input parameters, it's still not safe.
Tony Truong wrote: Only proper user input parsing and filtering will solve the security risks you mention.
This is not true.
Tony Truong wrote: What's to stop a user from entering sql statements inside the "message" input textbox.
A few things. ADO.NET has provisions for this. If you use an SqlCommand object and its Parameters collection to build either the SQL statement or the stored procedure call, then you are safe.
If you want more details, there is an article on MSDN[^] that deals with security in ASP.NET applications. It includes a section on SQL injection attacks.
Jeffrey
Everything should be as simple as possible, but not simpler. -- Albert Einstein http://www.extremeoptimization.com/
|
| Sign In·View Thread·PermaLink | 5.00/5 |
|
|
|
 |
|
 |
My original response was meant to be platform/language independent... What I meant is that the act of implementing a stored procedure does not prevent sql code injection... Moreso, your code must filter user input for the security reasons mentioned. Here, ADO.NET's SQLParameter class does the filtering for you... In essense, you can use the SQLParameter class in commandtext instead of stored procedures and get the same secutiry measures (assuming the SqlCommand class allows you to the use SQLParameter with commandtext.. if not you can implement a varation of the SqlCommand class)
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
Hi this must be a very stupid question...I´m a beginner...but I get this message when I press submit: ---------------------------------------------------------- RunTineError etc....
Details: To enable the details of this specific error message to be viewable on remote machines, please create a tag within a "web.config" configuration file located in the root directory of the current web application. This tag should then have its "mode" attribute set to "Off".
<!-- Web.Config Configuration File -->
-----------------------------------------------
Now what am I supposed to do? please help me!
|
| Sign In·View Thread·PermaLink | 2.00/5 |
|
|
|
 |
|
 |
Place the following in a file and name it web.config, and place in the folder where you have you're web.
<?xml version="1.0" encoding="utf-8" ?> <configuration> <system.web> <compilation defaultLanguage="c#" debug="true" /> <customErrors mode="RemoteOnly" />
<!-- APPLICATION-LEVEL TRACE LOGGING Application-level tracing enables trace log output for every page within an application. Set trace enabled="true" to enable application trace logging. If pageOutput="true", the trace information will be displayed at the bottom of each page. Otherwise, you can view the application trace log by browsing the "trace.axd" page from your web application root. --> <trace enabled="true" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true" />
<!-- SESSION STATE SETTINGS By default ASP.NET uses cookies to identify which requests belong to a particular session. If cookies are not available, a session can be tracked by adding a session identifier to the URL. To disable cookies, set sessionState cookieless="true". --> <sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;user id=sa;password=" cookieless="false" timeout="20" />
<!-- GLOBALIZATION This section sets the globalization settings of the application. --> <globalization requestEncoding="utf-8" responseEncoding="utf-8" /> </system.web> </configuration>
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Could anyone give me some insite on how to add a search option to this, and then display those results. This is probably asking a lot from a message board, but is there any examples that could be found? Thanks
|
| Sign In·View Thread·PermaLink | 1.00/5 |
|
|
|
 |
|
 |
I've done loaded the guestbook files and run them on our server. However I got the following errors. Looks very likely it is our server permision problem. Any idea or hint about this problem and how to solve it? Thank you very much for your help.
********** Below is the error message *************
Operation must use an updateable query. 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: Operation must use an updateable query.
Source Error:
Line 13: Dim cmd as New OleDBCommand (MySQL, MyConn) Line 14: MyConn.Open () Line 15: cmd.ExecuteNonQuery () Line 16: MyConn.Close () Line 17:
Source File: c:\inetpub\wwwroot\xli\AccessGuest\guestbook.aspx Line: 15
Stack Trace:
[OleDbException (0x80004005): Operation must use an updateable query.]
|
| Sign In·View Thread·PermaLink | 1.67/5 |
|
|
|
 |
|
|
 |
|
 |
It is our server permission problem. The problem has been solved. Your codes work perfectly now.
Thank you very much.
 
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
Forget it just found it... thanks anyway... infact the answer was rather obvious which is not without a sense of irony
|
| Sign In·View Thread·PermaLink | 3.00/5 |
|
|
|
 |
|
|
 |
|
|
 |
|
|
 |
|
|
 |
|
|
 |