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 _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["conn"]);
conn.Open();
SqlDataAdapter cmd = new SqlDataAdapter("select * from userreg",conn);
DataSet ds = new DataSet();
cmd.Fill(ds,"userreg");
if (表里有数据)
{
循环输出lable1.text的值
}
else
{
Label1.Text = "暂无用户注册!";
}
conn.Close();
}
}
这段码,用中文的表示我想实现这样的目地,但我不会写,大家看看该改的改该删的删,该加的加,不过不要复杂了,我新手,复杂的看不懂。
目地是查表里有没有数据,有就用lable1循环输出,没有就显示暂无用户注册!
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 _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["conn"]);
conn.Open();
SqlDataAdapter cmd = new SqlDataAdapter("select * from userreg",conn);
DataSet ds = new DataSet();
cmd.Fill(ds,"userreg");
if (表里有数据)
{
循环输出lable1.text的值
}
else
{
Label1.Text = "暂无用户注册!";
}
conn.Close();
}
}
这段码,用中文的表示我想实现这样的目地,但我不会写,大家看看该改的改该删的删,该加的加,不过不要复杂了,我新手,复杂的看不懂。
目地是查表里有没有数据,有就用lable1循环输出,没有就显示暂无用户注册!
解决方案 »
- Socket问题:每个套接字地址只允许使用一次、无法访问已释放的对象
- C#服务器端保存几千条,上万条用户信息
- 1-2+3-4+...+m,有几种方法可以解决
- 几个关于listBox和label的小问题
- C# 如何调用不注册的ActiveX Dll(Vb6写的)
- 帮忙看一下Linq语句为什么随机出现错误???
- C#如何查看MSMQ里的消息,并能进行删除操作,有人知道吗?
- 如何编写一个tcpclient实时监听服务器是否有数据传送过来?
- 收邮件解码问题?该样解码?
- Windows Application技术难题,请顶尖高手帮忙解决,分不够可以再加!
- 请问在哪里可以下载到XML读写类?
- 图片输出在客户端还是服务器
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Data;namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
// "uid=sa":连接数据库的用户名为sa.
// "password=":连接数据库的验证密码为空.他的别名为"pwd",所以我们可以写为"pwd=".
// "initial catalog=Northwind":使用的数据源为"Northwind"这个数据库.他的别名为"Database",本句可以写成"Database=Northwind".
// "Server=YourSQLServer":使用名为"YourSQLServer"的服务器.他的别名为"Data Source","Address","Addr".
// " Connect Timeout=30":连接超时时间为30秒.(根据情况添加)
// PS:
// 1.你的SQL Server必须已经设置了需要用户名和密码来登录,否则不能用这样的方式来登录.如果你的SQL Server设置为Windows登录,那么在这里就不需要使用"uid"和"password"这样的方式来登录,而需要使用"Trusted_Connection=SSPI"来进行登录.
// 2. 如果使用的是本地数据库且定义了实例名,则可以写为"Server=(local)\实例名";如果是远程服务器,则将"(local)"替换为远程服务器的名称或IP地址.
string strConnection = "Trusted_Connection=SSPI;";
strConnection += "database=NTF_Navision_enlistment60;Server=CAIXIATA-6BE823;";
strConnection += "Connect Timeout=30";
using (SqlConnection objConnection = new SqlConnection(strConnection))
{
objConnection.Open();
// method 1
SqlCommand myCommand = new SqlCommand("select * from Couse", objConnection); Console.WriteLine("open");
SqlDataReader myReader = myCommand.ExecuteReader();
while (myReader.Read())
{
Console.WriteLine(myReader.GetFieldType(0));
Console.WriteLine(myReader.GetFieldType(1));
Console.WriteLine(myReader.GetFieldType(2));
Console.WriteLine(myReader.GetDecimal(0));
Console.WriteLine(myReader.GetDecimal(1));
Console.WriteLine(myReader.GetDecimal(2));
}
myReader.Close(); // method 2
SqlDataAdapter myCommandd = new SqlDataAdapter("select * from Couse", objConnection);
DataSet ds = new DataSet();
myCommandd.Fill(ds, "Couse");
DataTable dt = ds.Tables["couse"];
Console.WriteLine(dt.Columns[0].ToString());
Console.WriteLine(dt.DefaultView.Count);
}
}
}
}本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/LCL_data/archive/2009/04/30/4139145.aspx
{
//
}