佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

楼主: shinelynn

.net 求救 (Server.MapPath)

[复制链接]
发表于 15-2-2007 10:44 PM | 显示全部楼层
暂时还不清楚你的 code 有什么问题... 但有没有 trace 看 code 里面的 value? 或你先选择 Loc 1 和 loc 3 看看行不行?
回复

使用道具 举报


ADVERTISEMENT

 楼主| 发表于 23-2-2007 10:28 AM | 显示全部楼层
单选的话,Loc 1 和Loc 3还是不能出来,Loc 2 和Grand Total就没问题。我想不出这两个column到底有什么问题。

我尝试把这两个column在excel里换去“text”先,就没问题了。虽然是没问题了,可是还是觉得很不逻辑,为什么Loc 2 和 Grand Total 是number,可以display到,Loc 1 和 Loc 3 也是number却不可以。。
回复

使用道具 举报

发表于 26-2-2007 09:38 AM | 显示全部楼层

回复 #102 shinelynn 的帖子

回答不上来... 只能归于是 Excel 的 bug...
回复

使用道具 举报

 楼主| 发表于 17-8-2007 03:11 PM | 显示全部楼层
简单的asp.net,onclick button时,button的text应该换去"You clicked me!",可是为什么按了button,它的text没换到的。。

<script runat="server">
    Sub submit(ByVal Source As Object, ByVal e As EventArgs)
        button1.Text = "You clicked me!"
    End Sub
</script>

<html>
<body>
<form runat="server">
    <asp:Button ID="button1" Text="Click me!" runat="server" OnClick="submit"
/>
</form>
</body>
</html>
回复

使用道具 举报

发表于 20-8-2007 02:35 PM | 显示全部楼层
按下去的时候, 发生了什么事? 有没有 error? 有没有完整的 code?
回复

使用道具 举报

 楼主| 发表于 20-8-2007 03:16 PM | 显示全部楼层

回复 #105 goatstudio 的帖子

这就是完整的code了,我从w3schools练习的code来的。

http://www.w3schools.com/aspnet/showasp.asp?filename=demo_button

没有error,只是button的text没换到,click了没response。因为我刚install了vs2005,想试试看能不能走。是不是少set up什么了?
回复

使用道具 举报

Follow Us
发表于 21-8-2007 01:12 AM | 显示全部楼层

回复 #106 shinelynn 的帖子

test 了,没问题呀。。。
回复

使用道具 举报

 楼主| 发表于 21-8-2007 09:25 AM | 显示全部楼层

回复 #107 SKYLINE84 的帖子

妈啊有鬼,我今天又试,却可以了!

谢谢。
回复

使用道具 举报


ADVERTISEMENT

发表于 21-8-2007 09:29 AM | 显示全部楼层
七月了。。。咳。。。
回复

使用道具 举报

 楼主| 发表于 27-8-2007 11:40 AM | 显示全部楼层
我不明白namespace是要做莫的,我用vs.net 2003 create的project,全部item (asp.net,class)都会under同一个namespace (namespace assinged automatically to every item following the project name)。

我现在用vs2005,这些item都没有under一个namespace的,而且我create的class是被放进App_Code的folder里面,我用一个asp.net的page call class里面的function都call不到的。。之前用vs.net 2003有namespace就没问题。我现在想要把namespace manually加进每一个item,加了又有error的。。。。。。做莫会酱。。。

DataServer.cs,放在App_Code里,

    public class DataServer
    {
        private OleDbConnection ReqDBConn;
        private OleDbCommand ReqDBCmd;
        private OleDbDataAdapter ReqDBAdapter;
        private DataTable ReqDBTable;

        private string ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;data
source = db_test.mdb";

        public string fLogIn(string strUsrID, string strUsrPwd)
        {
            .....
        }

        public string cstr(string strText)
        {
        .....
        }
    }

其中一个asp.net在button on click时,

DataServer ds = new DataServer();
strLogIn = ds.fLogIn(txtUsrName.Text, txtPwd.Text);

IE有error说,

Compilation Error
Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.

Compiler Error Message: CS0246: The type or namespace name 'DataServer'
could not be found (are you missing a using directive or an assembly reference?)


Source Error:


Line 31:                 string strLogIn;
Line 32:
Line 33:                 DataServer ds = new DataServer();
Line 34:                 strLogIn = ds.fLogIn(txtUsrName.Text, txtPwd.Text);

救命啊。。。。。
回复

使用道具 举报

发表于 28-8-2007 12:46 AM | 显示全部楼层
看来看去都看不出你code有什么问题?把整段放上来如何?
回复

使用道具 举报

发表于 28-8-2007 10:01 AM | 显示全部楼层
你的 DataServer 是不是在一个独立的 DLL?
回复

使用道具 举报

 楼主| 发表于 29-8-2007 12:47 PM | 显示全部楼层
Data Server
using System;
using System.Data;
using System.Data.OleDb;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
/// <summary>
///
Summary description for DataServer
/// </summary>
///


public class DataServer
{
   private OleDbConnection ReqDBConn;
   private OleDbCommand ReqDBCmd;
   private OleDbDataAdapter ReqDBAdapter;
   private DataTable ReqDBTable;
   private string ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;data source = dbSalon.mdb";
   
   public string fLogIn(string strUsrID, string strUsrPwd)
   {
      try
      {
      //Create New ConnectSion
      ReqDBConn = new OleDbConnection(ConnStr);
      //Create new data table to hold data
      ReqDBTable = new DataTable();
      //Create new data adapter
      ReqDBAdapter = new OleDbDataAdapter();
      //Connect select command to database
      ReqDBCmd = ReqDBConn.CreateCommand();
      ReqDBCmd.CommandText =
"SELECT * FROM TBL_USR WHERE USRNAME = '" + strUsrID + "'";
      ReqDBAdapter.SelectCommand = ReqDBCmd;
      ReqDBAdapter.Fill(ReqDBTable);
      string strPwd;
      strPwd =
"Fail";
      foreach (DataRow ReqDBRow in ReqDBTable.Rows)
      {
         strPwd = ReqDBRow[
"USRPWD"].ToString();
         if (strUsrPwd == strPwd)
         {
            strPwd =
"Success";
         }
         else
         {
             strPwd =
"Fail";
         }
       }
      return strPwd;
      }
      catch (Exception e)
      {
         return (Convert.ToString(e));
      }
   }

}


slogin.aspx.cs
public partial class slogin : System.Web.UI.Page
{
   protected void Page_Load(object sender, EventArgs e)
   {
   }

   protected void btnEnter_Click(object sender, EventArgs e)
   {
      if (txtUsrName.Text == "")
      {
         lblMsg.Text =
"Please enter username";
      }
         else if (txtPwd.Text == "")
      {
         lblMsg.Text =
"Please enter password";
      }
         else
      {
         string strLogIn;
         DataServer ds = new DataServer();
         strLogIn = ds.fLogIn(txtUsrName.Text, txtPwd.Text);
         if (strLogIn == "Success")
         {
         }
         else
         {
         lblMsg.Text =
"Invalid Password!";
         }
      }
   }
}




DLL是c# class的意思吗? 我想把DataServer.cs放进和project同一个folder (和其他的aspx在一起),可是有warning message叫我放进project里头的一个叫App_Code的folder。

可以问下为什么project没有namespace的?
回复

使用道具 举报

发表于 29-8-2007 06:42 PM | 显示全部楼层
原帖由 shinelynn 于 29-8-2007 12:47 PM 发表
Data Server


slogin.aspx.cs




DLL是c# class的意思吗? 我想把DataServer.cs放进和project同一个folder (和其他的aspx在一起),可是有warning message叫我放进project里头的一个叫App_Code的folder ...

俺机子上试了没问题
自制.cs class 必须放在App_Code里头,这是规矩,放在其他地方它会找不到说。web page不需要namespace
回复

使用道具 举报

 楼主| 发表于 29-8-2007 07:03 PM | 显示全部楼层

回复 #114 神仙祖宗 的帖子

啊,天啊! 可是我的做莫不行?
回复

使用道具 举报

发表于 29-8-2007 08:16 PM | 显示全部楼层
是不是你其他dll (bin folder) 里面也有DataServer这个Class?
试试换个名字?
回复

使用道具 举报


ADVERTISEMENT

发表于 30-8-2007 08:15 AM | 显示全部楼层

回复 #115 shinelynn 的帖子

七月中。。。。。。。。。。。。。
回复

使用道具 举报

 楼主| 发表于 30-8-2007 10:01 AM | 显示全部楼层
回复 #116 神仙祖宗 的帖子

没有,只有一个。我其实有一个问题,可是不知道有没有关系。在Tools ->Options那里的setting,under Projects and Solutions,有Visual Studio projects location, Visual Studio user project templates location和Visual Studio user item templates location,我全部把它们还去C:\Inetpub\wwwroot了,本来的path是Visual Studio 2005里头了。

我换了path之后,每当我create一个project时,它会auto create另一个同样的folder给我,比如说,

我create了,"TestSys",就有一个folder created under C:\Inetpub\wwwroot,可是,不知怎么的,它auto create了"TestSys(2)",然后把TestSys.sln solution放进这folder里头,是不是因为这样我compile不到?


回复 #117 johe07 的帖子
我组屋这里有放白布电影,一晚放两套戏,我昨晚还开tv2的LOTR和外头的倩女幽魂斗大声。可能就因为这样。。。。。。
回复

使用道具 举报

发表于 30-8-2007 08:39 PM | 显示全部楼层

回复 #118 shinelynn 的帖子

虽然没试过,不过照理说换那些path不会造成compile error。一定有其它原因,换了名字(DataServer)也一样么?
回复

使用道具 举报

 楼主| 发表于 3-9-2007 08:02 AM | 显示全部楼层
原帖由 神仙祖宗 于 30-8-2007 08:39 PM 发表
虽然没试过,不过照理说换那些path不会造成compile error。一定有其它原因,换了名字(DataServer)也一样么?


解决了谢谢,我去IIS那里把这project加进了Virtual Directory,原来要manually加的才行啊?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT


本周最热论坛帖子本周最热论坛帖子

ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 24-9-2025 09:36 PM , Processed in 0.149666 second(s), 21 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表