C#如果我想列出数据库内的表Table的所有数据,那么接下来该怎么写?
App.config类。usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem....
App.config
类。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Data;
using System.Data.Sql;
namespace ConsoleApplication1
{
class Program
{
class A
{
public A()
{
string sqlstr = ConfigurationManager.ConnectionStrings["SqlServer"].ConnectionString;
}
}
static void Main(string[] args)
{
}
}
} 展开
类。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Data;
using System.Data.Sql;
namespace ConsoleApplication1
{
class Program
{
class A
{
public A()
{
string sqlstr = ConfigurationManager.ConnectionStrings["SqlServer"].ConnectionString;
}
}
static void Main(string[] args)
{
}
}
} 展开
推荐于2016-06-24
展开全部
qlConnection conn=new SqlConnection(sqlstr );
conn.Open();
SqlCommand sqlcmd=new SqlCommand();
sqlcmd.CommandText ="select * from student";
sqlcmd.Connection=conn;
SqlDataAdapter adp=new SqlDataAdapter(sqlcmd);
DataTable dt=new DataTable();
adp.Fill(dt);
conn.Open();
SqlCommand sqlcmd=new SqlCommand();
sqlcmd.CommandText ="select * from student";
sqlcmd.Connection=conn;
SqlDataAdapter adp=new SqlDataAdapter(sqlcmd);
DataTable dt=new DataTable();
adp.Fill(dt);
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询