'/'应用程序中的服务器错误。无法使用'';文件已在使用中。 [英] Server Error in '/' Application. Could not use ''; file already in use.

查看:140
本文介绍了'/'应用程序中的服务器错误。无法使用'';文件已在使用中。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!!





我收到错误

Hi !!


I am getting Error "

Server Error in ''/'' Application. Could not use ''''; file already in use.<pre> Its run complete on my local host but when  I upload that webpade on server I am getting above error.Any one can provide me solution for this problem !! 

My Coding is below


<blockquote class="FQ"><div class="FQA">Quote:</div>Imports System.Data.OleDb

Partial Class Login
    Inherits System.Web.UI.Page

    Dim cn As OleDbConnection
    Dim cmd As OleDbCommand
    Dim A As String
    Dim adptr As OleDbDataAdapter
    Dim DR As OleDbDataReader


    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click


        A = "Select Password1 from Security1 where UserName=''" & TxtUser.Text & "''"

        cmd = New OleDbCommand(A, cn)

        DR = cmd.ExecuteReader()

        DR.Read()

        If DR.HasRows = True Then

            If TxtPassword.Text = DR.GetValue(0) Then

                Session("UserName") = TxtUser.Text

                If TxtUser.Text = "admin" Then
                    cn.Close()
                    Response.Redirect("Admin.aspx")
                End If


            End If

            Label1.Text = " Invalid Password "
        End If




    End Sub
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load


        cn = New OleDbConnection("Provider = Microsoft.Jet.Oledb.4.0;data source=" & Server.MapPath("DEO.mdb"))
        cn.Open()

        cmd = New OleDbCommand(" select * from Security1", cn)

        cmd.ExecuteNonQuery()


    End Sub
End Class</blockquote>

推荐答案

当然它正在使用中!

您甚至不想尝试关闭它,因此您必须等到会话超时并且在连接之前卸载应用程序重新关闭。



数据库连接是稀缺资源 - 创建它们,使用它们,处理它们。

其他明智的你会遇到问题每次都这样。



和顺便说一句:如果你真的喜欢你的数据库,就不要这样做!你可以向全世界任何地方的任何人敞开大门,删除你的整个数据库,甚至不用尝试登录。不要连接字符串来构建SQL命令。它让您对意外或故意的SQL注入攻击持开放态度,这可能会破坏您的整个数据库。改为使用参数化查询。



并且不要让我开始使用明文存储密码的网站!阅读本文,在下一个访问您网站的人员之前,只需读出您的整个用户名和密码列表:密码存储:怎么做。 [ ^ ]



你为什么要酝酿自己的?为什么不使用会员资格 - 它很简单,它很安全,它可以为您节省大量时间和麻烦! http://msdn.microsoft.com/en-GB/library/yh26yfzy (v = vs.100).aspx [ ^ ]
Of course it''s in use!
You don''t even try to close it, so you will have to wait until the session times out and the app is unloaded before your connection is re-closed.

DB connections are scarce resources - create them, use them, dispose them.
Other wise you will get problems like that every time.

And BTW: if you really like your database don''t do things like that! You leave yourself wide open to anyone, anywhere in the world deleteing your entire databse without even trying to log in. Do not concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Use Parametrized queries instead.

And don''t get me started on sites that store passwords in clear text! Read this, before the next person to visit your site just read out your entire username and password list: Password Storage: How to do it.[^]

Why are you "brewing your own" at all? Why not use Membership - it''s easy, it''s secure, and it saves you a lot of time and hassle! http://msdn.microsoft.com/en-GB/library/yh26yfzy(v=vs.100).aspx[^]


这篇关于'/'应用程序中的服务器错误。无法使用'';文件已在使用中。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆