using System;
using System.Data;
using System.Configuration;
using System.Collections;
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;
using System.Data.SqlClient;public partial class vote : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string a = DateTime.Today.ToString();
SqlConnection Conn = new SqlConnection("server=ACDBA7FC19684F8\\SQLEXPRESS;database=abc;uid=zyl;pwd=123456");
//此处需改为自己的连接
string sql = "select * from vote where r1< '" + a + "' and r2 > '" + a + "' ";
SqlDataAdapter Comm = new SqlDataAdapter(sql, Conn);
DataSet ds = new DataSet();
Comm.Fill(ds, "vote");
if(ds.Tables[0].Rows.Count>0)
{
Label6.Text = ds.Tables[0].Rows[0]["title"].ToString();
Label1.Text = ds.Tables[0].Rows[0]["Vname1"].ToString();
Label3.Text = ds.Tables[0].Rows[0]["Vname2"].ToString();
Label5.Text = ds.Tables[0].Rows[0]["Vname3"].ToString();
Label7.Text = ds.Tables[0].Rows[0]["Vname4"].ToString();
}
else
{
Response.Write("表中无记录");
}
}
using System.Data;
using System.Configuration;
using System.Collections;
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;
using System.Data.SqlClient;public partial class vote : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string a = DateTime.Today.ToString();
SqlConnection Conn = new SqlConnection("server=ACDBA7FC19684F8\\SQLEXPRESS;database=abc;uid=zyl;pwd=123456");
//此处需改为自己的连接
string sql = "select * from vote where r1< '" + a + "' and r2 > '" + a + "' ";
SqlDataAdapter Comm = new SqlDataAdapter(sql, Conn);
DataSet ds = new DataSet();
Comm.Fill(ds, "vote");
if(ds.Tables[0].Rows.Count>0)
{
Label6.Text = ds.Tables[0].Rows[0]["title"].ToString();
Label1.Text = ds.Tables[0].Rows[0]["Vname1"].ToString();
Label3.Text = ds.Tables[0].Rows[0]["Vname2"].ToString();
Label5.Text = ds.Tables[0].Rows[0]["Vname3"].ToString();
Label7.Text = ds.Tables[0].Rows[0]["Vname4"].ToString();
}
else
{
Response.Write("表中无记录");
}
}
解决方案 »
- 写了个存储过程不怎么会用
- 在页面后置代码中创建层
- 请问如何在html中调用服务端(.cs)中的方法?
- 第一次使用ajax出现"Microsoft JScript runtime error: 'Sys' is undefined" 异常?
- ajax是什么东东哟?
- 如何将string类型转换成ArrayList类型?
- 求一高效MSSQL分页存储过程
- asp.net wap开发问题
- 在html中可以引用后台编码的函数么?如果可以,怎么引用?
- 如何使浏览器在访问页面时得到加了乱码的URL,紧急求助!
- .net开发中如何去掉网址中的www.
- “System.Web.UI.WebControls.TreeNodeCollection.Add(System.Web.UI.WebControls.Tree
要判断列是否为空
为空了 ds.Tables[0].Rows[0]["Vname4"].ToString() 就错了