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

首頁 > 學院 > 開發設計 > 正文

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

2019-11-18 20:49:06
字體:
來源:轉載
供稿:網友
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.



發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 宜章县| 利辛县| 高淳县| 东阿县| 静乐县| 洪湖市| 霍州市| 尤溪县| 枣强县| 建始县| 盐源县| 安义县| 望江县| 无为县| 巴楚县| 伊吾县| 永清县| 丁青县| 延安市| 彭山县| 博爱县| 大城县| 南漳县| 苏尼特左旗| 库车县| 景宁| 绩溪县| 余姚市| 顺义区| 嘉兴市| 军事| 于都县| 新和县| 蓬安县| 灯塔市| 华池县| 东乌珠穆沁旗| 南投县| 肥城市| 长沙县| 肥城市|