网格视图绑定和asp.net中的sqlconnection [英] Gridview binding & sqlconnection in asp.net

查看:96
本文介绍了网格视图绑定和asp.net中的sqlconnection的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过ASP.Net页面与SQL数据库建立连接.我们如何在gridview中显示数据.给我完整的sqlconnection代码.请帮忙.

How can I make connection with SQL database with ASP.Net page. How we show our data in gridview. Give me complete code for sqlconnection. Please help.

推荐答案

看看MSDN上的一个简单教程:
GridView.DataBind方法 [ GridView演示 [手动数据绑定GridView [到GridView的数据绑定 [ CodeProject常见问题系列1:ASP.NET GridView [ ^ ]

也可以查看 CodeProject搜索 [ ^ ]和
Have a look on a simple tutorial on MSDN:
GridView.DataBind Method[^]
GridView Demo[^]

Manually Databinding a GridView[^]
DataBinding to GridView [^]

Refer:
CodeProject Frequently Asked Questions Series 1: The ASP.NET GridView[^]

Also have look on CodeProject Search[^] and Google[^]


只需使用以下代码:
Just Use Below Code:
con2 = new SqlConnection();
con2.ConnectionString = @"Your connection String";
con2.Open();


 string name = "select Field from tablename";
 SqlDataAdapter name_ad = new SqlDataAdapter(name, con2);
 DataSet name_ds = new DataSet();
 name_ad.Fill(name_ds);

 Gridview1.Datasource=name_ds;
 Gridview1.Databind();

Con2.close();



这将为您提供帮助,如果没有,请发布.



This will Help You, If not please Post it.


这篇关于网格视图绑定和asp.net中的sqlconnection的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆