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

首頁 > 開發 > 綜合 > 正文

Working With oledb Adapter

2024-07-21 02:23:49
字體:
來源:轉載
供稿:網友
 
submitted byuser leveldate of submissionmahesh chandbeginners06/19/2001
platform used: vs.net beta 2 (test build)
description of the article:
microsoft visual studio .net (vs.net afterwards) is full with data-bound controls and wizards. these controls and wizards help you to generate your applications in no time. you just set some properties of these controls and use wizards to generate your code. in couple of minutes, you develop a full-fledged working application.
in this series of articles, my first article is oledb data adapter controls in vs.net. in this article, i'll show you how to display data in a datagrid control by writing only one line of code. you just follow these simple steps:
step 1: create project
pick visual c#->windows application project and type your project name and pick a directory.

step 2: add oledb data adapter
drag an oledbdataadapter control from toolbox->data to your form. data adapter configuration wizard appears and it guides you towards to create your data adapter pbject.
first screen is about the wizard.

second screen will let you create a connection. if you already have connections, they are available in a drop down list. you either pick a connection from your list or create a new connection.

next page provides you options to use sql statements or stored procedures.

next step is to generate sql statement. you use query builder button to build a query.

this option let you pick your database tables.

and now you pick what columns you want to get data from the database to the dataadapter.

this page shows you your sql statement. you can even write sql statement by yourself (with no help of query builder).

last page shows you the activities wizard finished.

step 3: generate dataset
next step is to generate dataset and connect dataset to a dataview component. you generate a dataset by using "generate dataset" option in dataadapter's properties dialog -

generate dataset link shows you dataset. pick "new" option and type your dataset name. you can pick as many as tables you want from the list.

by clicking "ok" button, wizard generates a dataset and shows you it's properties dialog. you can change dataset name and other properties. "view schema" option shows you the xml schema for this dataset added by the wizard and "dataset properties" option shows you the properties.

this action adds one dataset derived class to your project. we're not going in to details of this class.

step 4: attach dataset with a dataview
now attach this dataset with a dataview. drag a dataview control from toolbox->data and set it's table property to your dataset's table.

step 5: attach dataview with the datagrid control and fill the dataset
now drag a datagrid control from toolbox->winfroms to the form and set its datasource property to dataview.

now fill the data from dataadapter to the dataset by calling dataadapter's fill method. i write this code after initializecomponent();
initializecomponent();
oledbdataadapter1.fill(dataset11);
build and run the project and see the result. i see my data in the datagrid control.




about the author: mahesh is admin and founder of c# corner.  mahesh has over 5+ years of programming experience in vc++, mfc, vb, sql server, atl/com, and com+. mahesh's background includes master's in computer science and b.sc. maths. other achievements are mcp in vc++ 6.0. he presently engaged with kruse, inc. downingtown, pa, us as a software engineer. more details...
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 汽车| 哈尔滨市| 西贡区| 中方县| 临朐县| 厦门市| 平顺县| 涡阳县| 同德县| 夏河县| 宣武区| 理塘县| 安远县| 霸州市| 襄垣县| 枣阳市| 凌源市| 贡觉县| 阿荣旗| 京山县| 襄樊市| 广南县| 房产| 五家渠市| 淮阳县| 湘阴县| 鄢陵县| 桐乡市| 含山县| 南昌市| 海林市| 东乡| 托克逊县| 阳谷县| 津南区| 永宁县| 南充市| 黔西县| 保靖县| 威海市| 肇源县|