SqlCommand selectCommand=con.CreateCommand();
selectCommand.CommandText="SELECT * FROM table where ID=1";
sqlDataAdapter1.SelectCommand=selectCommand;
con.Open();
sqlDataAdapter1.Fill(ds1,"table");
con.Close();
this.DataGrid1.DataBind();
代码如上,在其他页面(代码基本相同,只有数据库名称和查询条件不同)查询可以实现
但是在主页面却总是实现不了,不知道什么原因
selectCommand.CommandText="SELECT * FROM table where ID=1";
sqlDataAdapter1.SelectCommand=selectCommand;
con.Open();
sqlDataAdapter1.Fill(ds1,"table");
con.Close();
this.DataGrid1.DataBind();
代码如上,在其他页面(代码基本相同,只有数据库名称和查询条件不同)查询可以实现
但是在主页面却总是实现不了,不知道什么原因
解决方案 »
- 怎样在asp.net网站中运行exe文件
- qq互联登陆
- 后台session丢失问题,登陆进去点不了几下就退出来了,怎么回事啊????
- 菜鸟提问:请帮忙看下这个Updatecommand错在哪里
- 有没有什么方法可以使整个页面的控件text属性清空
- 如何在服务端取Ajax无刷新联动的二级,三级联动的值。
- 为什么我的DropDataList选择不了,数据从数据库中读出,我点按钮的时候总会跳回选择的第一个
- 大家对布尔型字段是怎么命名的?
- 菜鸟初学CSS,请问:为什么这个服务器控件Lable1不变色?
- TreeView可不可以实现拖放功能,若能,怎么实现,请高手指点,在线等待!
- 水晶报表10企业版求救,连不上报表报务器
- >>>求助<<< 有没有好一点的介绍在ASP.NET(C#)中使用存储过程的例子,或书?
selectCommand.CommandText="SELECT * FROM table where ID=1";
sqlDataAdapter1.SelectCommand=selectCommand;
con.Open();
sqlDataAdapter1.Fill(ds1,"table");
con.Close();
this.DataGrid1.DataSource=sqlDataAdapter1;//加上这句试试。
this.DataGrid1.DataBind();
this.DataGrid1.DataBind();
{
if(!Page.IsPostBack)
{
绑定的总数据源
}
}
selectCommand.CommandText="SELECT * FROM table where ID=1";
sqlDataAdapter1.SelectCommand=selectCommand;
//con.Open();
sqlDataAdapter1.Fill(ds1);
//con.Close();
this.DataGrid1.DataSource = ds1;
this.DataGrid1.DataBind();
Dim myConn As OracleConnection = New OracleConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim myCommand As OracleDataAdapter = New OracleDataAdapter(mySQL, myConn) myCommand.Fill(myDataSet) Return myDataSet
SqlCommand selectCommand=con.CreateCommand();
selectCommand.CommandText="SELECT * FROM table where ID=1";
sqlDataAdapter1.SelectCommand=selectCommand;
con.Open();
sqlDataAdapter1.Fill(ds1,"table");
con.Close(); //以上应该没有问题
////--------------///
this.DataGrid1.DataSource = ds1.Tables["table"]; //你怎么没有??
this.DataGrid1.DataBind();
selectCommand.CommandText="SELECT * FROM table where ID=1";
sqlDataAdapter1.SelectCommand=selectCommand;
//con.Open();
sqlDataAdapter1.Fill(ds1);
//con.Close();
this.DataGrid1.DataSource = ds1;
this.DataGrid1.DataBind();
this.DataGrid1.DataSource = ds1.Tables["table"]; 加上了试了一下还是不行
不是数据绑定问题,因为可以得到所有值,不论是否符合查询条件
我个人认为你的问题并不是很严重,关键是你没有正确的进行跟踪调试! 先分析再调试很重要,不易南辕北辙!!!