asp教程.net C# 查询数据库教程中的日期字段类型及查询数据
private void button1_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection(@"");
//创建数据库连接对象、数据库连接字符串
SqlCommand cmd = conn.CreateCommand();
cmd.CommandText = "select * from thing where date = '" + dateTimPicker1.Value + "'";
SqlDataReader reader = cmd.ExecuteReader();while (reader.Read())
{
string xierushijian = reader.GetString(1);
string dotime = reader.GetString(2);
string thingscontent = reader.GetString(3);
textBox3.Text = ("写入时间:" + xierushijian + "做此事的时间:" + dotime + "事项内容:" + thingscontent);
}
}
%>
再一个asp.net教程查询数据库的内容简单实例
<%@Import Namespace="System.Data"%>
<%@Import Namespace="System.Data.SqlClient"%>
Hello World.www.111com.net