Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 asp.net and ACL

Author  Topic 

ying
Starting Member

4 Posts

Posted - 2004-05-19 : 22:21:56
I want to logion my network station according to user name at different virtual directory,when I gave my different virtual directory
a user that is everyone. This is following that is right.
<%@ Page Language="C#" Debug="true" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>

<html>

<script runat="server">

SqlConnection myConnection;


protected void Page_Load(Object sender, EventArgs e)
{
myConnection = new SqlConnection("");

if (!IsPostBack)
BindGrid("ID");
}

protected void MyDataGrid_Sort(Object sender, DataGridSortCommandEventArgs e)
{
BindGrid(e.SortExpression);
}

public void BindGrid(String sortfield)
{
SqlDataAdapter myCommand = new SqlDataAdapter("select * from dl_zongtable", myConnection);

DataSet ds = new DataSet();
myCommand.Fill(ds, "dl_zongtable");

DataView Source = ds.Tables["dl_zongtable"].DefaultView;
Source.Sort = sortfield;

MyDataGrid.DataSource=Source;
MyDataGrid.DataBind();
}







public void MyDataGrid_Delete(Object sender, DataGridCommandEventArgs e)
{
String deleteCmd = "DELETE from dl_zongtable where ID= @ID";
SqlCommand myCommand = new SqlCommand(deleteCmd, myConnection);
myCommand.Parameters.Add(new SqlParameter("@ID", SqlDbType.Int, 4));
myCommand.Parameters["@ID"].Value = MyDataGrid.DataKeys[(int)e.Item.ItemIndex];

myCommand.Connection.Open();

try
{
myCommand.ExecuteNonQuery();
Message.InnerHtml = "<b>Record Deleted</b><br>" + deleteCmd;
}
catch (SqlException)
{
Message.InnerHtml = "ERROR: Could not delete record";
Message.Style["color"] = "red";
}

myCommand.Connection.Close();

BindGrid();
}

public void BindGrid()
{
SqlDataAdapter myCommand = new SqlDataAdapter("select * from dl_zongtable", myConnection);

DataSet ds = new DataSet();
myCommand.Fill(ds, "dl_zongtable");

MyDataGrid.DataSource=ds.Tables["dl_zongtable"].DefaultView;
MyDataGrid.DataBind();


}

</script>

<body style="font: 10pt verdana">

<form runat="server">

<h3><font face="Verdana">Deleting a Row of Data</font></h3>

<span id="Message" EnableViewState="false" style="font: arial 11pt;" runat="server"/><p>

<ASP:DataGrid id="MyDataGrid" runat="server"
Width="800"
BackColor="#ccccff"
BorderColor="black"
ShowFooter="false"
CellPadding=3
CellSpacing="0"
Font-Name="Verdana"
Font-Size="8pt"
HeaderStyle-BackColor="#aaaadd"
AllowSorting="true"
AutoGenerateColumns="false"
DataKeyField="ID"
OnDeleteCommand="MyDataGrid_Delete"
>

<Columns>
<asp:ButtonColumn Text="Delete record" CommandName="Delete"/>
<asp:BoundColumn HeaderText="ID" SortExpression="ID" DataField="ID" ItemStyle-Wrap="false"/>
<asp:BoundColumn HeaderText="definecode" SortExpression="definecode" DataField="definecode"/>
<asp:BoundColumn HeaderText="pjname" SortExpression="pjname" DataField="pjname"/>
<asp:BoundColumn HeaderText="num" SortExpression="num" DataField="num"/>
<asp:BoundColumn HeaderText="dwname" SortExpression="dwname" DataField="dwname"/>
<asp:BoundColumn HeaderText="startime" SortExpression="startime" DataField="startime"/>
<asp:BoundColumn HeaderText="endtime" SortExpression="endtime" DataField="endtime"/>
<asp:BoundColumn HeaderText="waittime" SortExpression="waittime" DataField="waittime"/>
</Columns>

</ASP:DataGrid>

</form>

</body>
</html>
But when my different virtual directory have no the user of everyone,Running is wrong :
¡°/ysgs¡±Ó¦ÓóÌÐòÖеķþÎñÆ÷´íÎó¡£
--------------------------------------------------------------------------------

¶Ô¡°G:\sample\¡±µÄ·ÃÎʱ»¾Ü¾ø¡£Î´ÄÜ¿ªÊ¼¼àÊÓÎļþ¸ü¸Ä¡£
˵Ã÷: Ö´Ðе±Ç° Web ÇëÇóÆÚ¼ä£¬³öÏÖδ´¦ÀíµÄÒì³£¡£Çë¼ì²é¶ÑÕ»¸ú×ÙÐÅÏ¢£¬ÒÔÁ˽âÓйظôíÎóÒÔ¼°´úÂëÖе¼Ö´íÎóµÄ³ö´¦µÄÏêϸÐÅÏ¢¡£

Òì³£ÏêϸÐÅÏ¢: System.Web.HttpException: ¶Ô¡°G:\sample\¡±µÄ·ÃÎʱ»¾Ü¾ø¡£Î´ÄÜ¿ªÊ¼¼àÊÓÎļþ¸ü¸Ä¡£

Ô´´íÎó:

Ö´Ðе±Ç° Web ÇëÇóÆÚ¼äÉú³ÉÁËδ´¦ÀíµÄÒì³£¡£¿ÉÒÔʹÓÃÏÂÃæµÄÒì³£¶ÑÕ»¸ú×ÙÐÅϢȷ¶¨ÓйØÒì³£Ô­ÒòºÍ·¢ÉúλÖõÄÐÅÏ¢¡£

¶ÑÕ»¸ú×Ù:


[HttpException (0x80070005): ¶Ô¡°G:\sample\¡±µÄ·ÃÎʱ»¾Ü¾ø¡£Î´ÄÜ¿ªÊ¼¼àÊÓÎļþ¸ü¸Ä¡£]
System.Web.DirMonCompletion..ctor(DirectoryMonitor dirMon, String dir, Boolean watchSubtree, UInt32 notifyFilter) +139
System.Web.DirectoryMonitor.StartMonitoring() +42
System.Web.DirectoryMonitor.StartMonitoringFile(String file, FileChangeEventHandler callback, String alias) +154
System.Web.FileChangesMonitor.StartMonitoringDirectoryRenamesAndBinDirectory(String dir, FileChangeEventHandler callback) +278
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +331

[HttpException (0x80004005): ASP.NET ³õʼ»¯´íÎó]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +964
System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +128




--------------------------------------------------------------------------------
°æ±¾ÐÅÏ¢: Microsoft .NET Framework °æ±¾:1.1.4322.573; ASP.NET °æ±¾:1.1.4322.573
Please gave me a way .Thank you.
   

- Advertisement -