下面代码是我借鉴——操作数据库的代码,请问要怎么执行,后缀要取什么?我用的开发工具是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>
<%@ 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>
在服务器创建一个虚拟目录;然后浏览这个.aspx文件就可以了!
------------
我还是不知道怎么做,能麻烦你说的详细点吗?我的机器上好象没装IIS的,是不是不能创建虚拟目录?