
gridview 绑定数据库
publicpartialclass_Default:System.Web.UI.Page{protectedvoidPage_Load(objectsender,Eve...
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Get_Data();
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void Get_Data()
{ SqlConnection con=new SqlConnection("Server=.;database=logins;uid=zys;pwd=123;");
SqlDataAdapter sda=new SqlDataAdapter();
sda.SelectCommand=new SqlCommand("select * fron person", con);
DataSet ds = new DataSet();
sda.Fill(ds,"p");
this.GridView1.DataSource=ds.Tables["p"];
this.GridView1.DataBind();
}
}
为什么我用vs2005老是提示错误呢,请高手帮我解决,我哪里错了 展开
{
protected void Page_Load(object sender, EventArgs e)
{
Get_Data();
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void Get_Data()
{ SqlConnection con=new SqlConnection("Server=.;database=logins;uid=zys;pwd=123;");
SqlDataAdapter sda=new SqlDataAdapter();
sda.SelectCommand=new SqlCommand("select * fron person", con);
DataSet ds = new DataSet();
sda.Fill(ds,"p");
this.GridView1.DataSource=ds.Tables["p"];
this.GridView1.DataBind();
}
}
为什么我用vs2005老是提示错误呢,请高手帮我解决,我哪里错了 展开
2个回答
展开全部
con没有打开
con.open();
sql语句写错了
你把from 写成了 fron
con.open();
sql语句写错了
你把from 写成了 fron

2023-07-25 广告
StormProxies是全球大数据IP资源服务商,其住宅代理网络由真实的家庭住宅IP组成,可为企业或个人提供满足各种场景的代理产品。点击免费测试(注册即送1G流量)StormProxies有哪些优势?1、IP+端口提取形式,不限带宽,IP...
点击进入详情页
本回答由Storm代理提供
展开全部
数据连接没有打开
private void Get_Data()
{ SqlConnection con=new SqlConnection("Server=.;database=logins;uid=zys;pwd=123;");
con.open();
SqlDataAdapter sda=new SqlDataAdapter();
sda.SelectCommand=new SqlCommand("select * fron person", con);
DataSet ds = new DataSet();
sda.Fill(ds,"p");
this.GridView1.DataSource=ds.Tables["p"];
this.GridView1.DataBind();
}
private void Get_Data()
{ SqlConnection con=new SqlConnection("Server=.;database=logins;uid=zys;pwd=123;");
con.open();
SqlDataAdapter sda=new SqlDataAdapter();
sda.SelectCommand=new SqlCommand("select * fron person", con);
DataSet ds = new DataSet();
sda.Fill(ds,"p");
this.GridView1.DataSource=ds.Tables["p"];
this.GridView1.DataBind();
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询