国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

ADO.NET:使用ADO.NET連接文本文件

2024-07-10 13:07:48
字體:
來源:轉載
供稿:網友
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.
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 工布江达县| 高雄县| 顺义区| 达日县| 邵阳市| 武冈市| 泸定县| 安阳市| 五寨县| 延长县| 红河县| 黄山市| 长丰县| 永福县| 元氏县| 陇南市| 得荣县| 昌宁县| 赣州市| 沛县| 湄潭县| 武清区| 阳高县| 金塔县| 马尔康县| 綦江县| 高清| 麦盖提县| 大邑县| 泸溪县| 高邮市| 娄烦县| 林州市| 四子王旗| 仲巴县| 临泉县| 南充市| 文昌市| 安阳市| 桦甸市| 黄大仙区|