html的
<html> <head></head> <body> 今天天气还不错,据说一会要下雨 </body> </html>
C#不连接数据库
<%@ language="C#" %>//1、告诉他用到的语音 <html> <head></head> <body> // DateTime.Now //2如果不写1会直接显示DateTime.Now。执行1,2变成3 <%= DateTime.Now %>//3、如果是html显示<%@ language="C#" %><%= DateTime.Now %>,执行4、把后缀成axps <% if( DateTime.Now.Hour>12) {%> xiawu %<} else {%> shangwu %<} %> </body> </html>
C#连接数据库
<%@ language="C#" %>//1、告诉他用到的语音 <%@import namespace ="System.Data.SqlClient" %>//2、引用命名空间 <html> <head></head> <body> <table> <tr> <td>用户名</td> <td>密码</td> <td>昵称</td> <td>性别</td> <td>民族</td> </tr> <% SqlConnection comm = new SqlConnection("server=.;database=Date0504;user=sa;pwd=y920106k"); SqlCommand cmd = conn.CreateCommand(); cmd.CommandText="select * from Users"; conn.Open(); SqlDataReader dr = cmd.ExecuteReader(); while(dr.Read()) { %> <tr> <td><%= dr["UserName"]%></td> <td><%= dr["PassWord"]%></td> <td><%= dr["NickName"]%></td> <td><%= dr["Sex"]%></td> <td><%= dr["Nation"]%></td> </tr> conn.Close(); <% } %> </table> </body> </html>
时间: 2024-10-23 15:36:44