求一个C#对数据库的增删改查代码和ListView的代码。
3个回答
展开全部
以下为SQL2005的数据库
string str = "data source=PAN-PC;uid=sa;pwd=123456;database=yun";
SqlConnection conn = new SqlConnection(str);
try
{
SqlCommand com = new SqlCommand();
com.Connection = conn;
com.CommandText = "select * from yun";
if (conn.State == ConnectionState.Closed)
{
conn.Open();
}
dateTable db =new dateTable();
sqldataApter da =new sqldataApter (com,conn);
da.file("db");
ListView.dataSource=da;
ListView.dataBound();//数据库的对ListView绑定
string str = "data source=PAN-PC;uid=sa;pwd=123456;database=yun";
SqlConnection conn = new SqlConnection(str);
try
{
SqlCommand com = new SqlCommand();
com.Connection = conn;
com.CommandText = "select * from yun";
if (conn.State == ConnectionState.Closed)
{
conn.Open();
}
dateTable db =new dateTable();
sqldataApter da =new sqldataApter (com,conn);
da.file("db");
ListView.dataSource=da;
ListView.dataBound();//数据库的对ListView绑定
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询