国产探花免费观看_亚洲丰满少妇自慰呻吟_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.
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 张家港市| 宜丰县| 五峰| 慈利县| 惠水县| 河津市| 开封市| 贵阳市| 铜梁县| 定结县| 定南县| 都江堰市| 三门县| 长海县| 桐乡市| 鹤壁市| 乌审旗| 会理县| 定兴县| 太康县| 柞水县| 商都县| 通渭县| 苏尼特左旗| 界首市| 漳平市| 沈丘县| 收藏| 巧家县| 眉山市| 白城市| 阳原县| 礼泉县| 襄垣县| 湟中县| 浦江县| 邹城市| 祁连县| 耒阳市| 安丘市| 彭水|