新手,希望大虾多帮忙

lovelihp 2005-06-16 05:57:25
下面代码是我借鉴——操作数据库的代码,请问要怎么执行,后缀要取什么?我用的开发工具是VS。NET 2003
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SQL" %>

<html>
<head>

<script language="C#" runat="server">
public SQLDataReader myReader;
public String html;

protected void Page_Load(Object Src, EventArgs E ) {
   SQLConnection mySQLConnection = new SQLConnection("server=localhost;uid=sa;pwd=;database=northwind");
   SQLCommand mySQLCommand = new SQLCommand("select * from customers", mySQLConnection);

   try {
      mySQLConnection.Open();
      mySQLCommd.Execute(out myReader);



      html="<Table>";
      html+="<TR>";
      html+="<TD><B>Customer ID</B>   </TD>";
      html+="<TD><B>Company Name</B></TD>";
      html+="</TR>";

      while (myReader.Read()) {
         html+="<TR>";
         html+="<TD + myReader["CustomerID"].ToString() + "</TD>";
 
         html+="<TD>" + myReader["CompanyName"].ToString() + "</TD>";
         html+="</TR>";
      }
      html+="</Table>";
   }
   catch(Exception e) {
      html=e.ToString();
   }
   finall y {
      meader.Close();

      mySQLConnection.Close();
   }
   Response.Write(html);
}
</script>
</head>

<body>

</body>
</html>
...全文
63 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
lovelihp 2005-06-16
  • 打赏
  • 举报
回复
在web服务器上,鼠标右键--〉创建虚拟目录到你的项目文件
------------
我还是不知道怎么做,能麻烦你说的详细点吗?我的机器上好象没装IIS的,是不是不能创建虚拟目录?
朝圆夜不圆 2005-06-16
  • 打赏
  • 举报
回复
在web服务器上,鼠标右键--〉创建虚拟目录到你的项目文件
lovelihp 2005-06-16
  • 打赏
  • 举报
回复
虚拟目录怎么创建啊???能说一下,谢谢
朝圆夜不圆 2005-06-16
  • 打赏
  • 举报
回复
后缀名是.aspx
在服务器创建一个虚拟目录;然后浏览这个.aspx文件就可以了!
lovelihp 2005-06-16
  • 打赏
  • 举报
回复
就是我想知道怎么执行这代码,我是刚刚接触。NET,不知道把这代码写在哪里?
thinkingforever 2005-06-16
  • 打赏
  • 举报
回复
”后缀要取什么?“没有看明白楼主的意思。

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧