system.data.dataadaptter.fill(... [英] system.data.dataadaptter.fill(...

查看:66
本文介绍了system.data.dataadaptter.fill(...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

protected void btnload_Click(object sender,EventArgs e)

{

String cs = ConfigurationManager.ConnectionStrings [ConnectionString]。ConnectionString;

SqlConnection con = new SqlConnection(cs);

SqlDataAdapter da = new SqlDataAdapter(select * from tblEmployee Where Id =+ TextBox1.Text,con);

数据集dset = new Dataset();

// da.Fill(dset,tblEmployee); //在这行中我得到错误原因?请帮帮我





}



先谢谢

protected void btnload_Click(object sender, EventArgs e)
{
String cs = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlConnection con = new SqlConnection(cs);
SqlDataAdapter da = new SqlDataAdapter("Select * from tblEmployee Where Id =" + TextBox1.Text,con);
Dataset dset = new Dataset();
// da.Fill(dset, "tblEmployee");// in this line iam getting the error why? please help me out


}

Thanks in advance

推荐答案

这里你只有一个表dd右边,所以为什么不尝试

Here you are having only one table in that ds dset right,so why dont you try
da.Fill(dset)



或者你可以使用


or you can use

da.Fill(dset.Tables["tblEmployee"])





我建议您使用数据表而不是ds。如果使用数据集,它会对性能产生负面印象。仅在需要时使用数据集。



在这里阅读更多



http://msdn.microsoft.com/en-us/library/905keexk%28v=vs.110% 29.aspx [ ^ ]



http://msdn.microsoft.com/en-us/library/ms171920.aspx [ ^ ]


这篇关于system.data.dataadaptter.fill(...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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