频道直达 - 学院 - 下载 - 交易 - 截图 - 特效 - 字库 - 手册 - 排名-工具 - 繁體
设为首页
加入收藏
联系我们
建站搜索: 虚拟主机  域名注册   常用广告代码      用户注册 | 用户登陆
您当前的位置:中国建站之家 -> 网站开发 -> Asp.Net -> 文章内容
精彩推荐
热门文章
· 注册码大全二
· 注册码大全四
· 注册码大全一
· 通过google 赶快来赚..
· [图文] 头像-qq头像(..
· 要10G免费网络硬盘的..
· 注册码大全三
· 注册码大全十
· [图文] 梦幻背景图片..
· [图文] 卡通动物图片..
相关文章
· 人大复印资料处理程序_输..
· 游走于ASP与ASP.NET的郁..
· Windows 2003负载平衡策..
· MySQL数据库技术(34)
· 关于如何操作其他窗体的..
· asp性能测试第二部分(转..
· 使用Photoshop制作环形文..
· 如何使用ASP在自己的网站..
· PS作品《对弈》解析:棋子..
· 十大照片优化秘籍(7)
ADO.NET:使用ADO.NET连接文本文件
作者:未知  来源:转载  发布时间:2005-9-17 0:21:42  发布人:acx

减小字体 增大字体

try
{
// create a new ADOConnection to the text file through ODBC and an existing Data Source
ADOConnection conn = new ADOConnection("Provider=MSDASQL;DSN=registrations;");
// create a DataSet Command that selects all the records from the registration.txt table (which in this case is a file)
ADODataSetCommand AdoCmd = new ADODataSetCommand("SELECT * FROM registrations.txt", conn);

// fill the dataset with the registration.txt table
AdoCmd.FillDataSet(dataSet1, "registrations.txt");
DataTable ContactTable = dataSet1.Tables[0];
int count = 0;

// loop through each row of the table and fill 15 rows of the listview
foreach (DataRow dr in ContactTable.Rows)
{
listView3.ListItems[count].Text = dr["LastName"].ToString();
listView3.ListItems[count].SetSubItem(0, dr["FirstName"].ToString());
listView3.ListItems[count].SetSubItem(1, dr["Company"].ToString());
listView3.ListItems[count].SetSubItem(2, dr["Address"].ToString());
count++;
if (count > 15)
{
break;
}
}
}
catch(ADOException ae)
{
Console.WriteLine(ae.Message.ToString());
}


That's all there is to it. This should also give you an idea of how to connect to databases through ODBC such as Oracle, Informix, Sybase, or Interbase. All you need to do is set up the appropriate Data Source through the Administration tools and use the code above to access your tables.
[打 印]
[] [返回上一页] [收 藏]
下一篇文章:ADO.NET:ADODataReader类
∷相关文章评论∷    (评论内容只代表网友观点,与本站立场无关!) [更多评论...]
关于本站 - 网站帮助 - 广告合作 - 下载声明 - 友情连接 - 网站地图 - 人才招聘
网站合作、内容监督、商务咨询:QQ: 9576619
Copyright ? 2005--2008 中国建站之家版权所有
未经授权禁止转载、摘编、复制或建立镜像.如有违反,追究法律责任.
免责申明:中国建站之家(www.jz123.cn)上的所有提供下载的软件和资源
均来源于网络,为软件或程序作者提供和网友推荐收集整理而来,仅供学习
和研究使用。如有侵犯你的版权,请立即联系我们,本站将在3个工作日内删除。
粤ICP备05092265号