欢迎光临
我们一直在努力

Working With oledb Adapter-.NET教程,数据库应用

建站超值云服务器,限时71元/月

 

submitted by user level date of submission
mahesh chand beginners 06/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, ill 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.
Working With oledb Adapter-.NET教程,数据库应用
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.
Working With oledb Adapter-.NET教程,数据库应用
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.
Working With oledb Adapter-.NET教程,数据库应用
next page provides you options to use sql statements or stored procedures.
Working With oledb Adapter-.NET教程,数据库应用
next step is to generate sql statement. you use query builder button to build a query.
Working With oledb Adapter-.NET教程,数据库应用
this option let you pick your database tables.
Working With oledb Adapter-.NET教程,数据库应用
and now you pick what columns you want to get data from the database to the dataadapter.
Working With oledb Adapter-.NET教程,数据库应用
this page shows you your sql statement. you can even write sql statement by yourself (with no help of query builder).
Working With oledb Adapter-.NET教程,数据库应用
last page shows you the activities wizard finished.
Working With oledb Adapter-.NET教程,数据库应用
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 dataadapters properties dialog –
Working With oledb Adapter-.NET教程,数据库应用
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.
Working With oledb Adapter-.NET教程,数据库应用
by clicking "ok" button, wizard generates a dataset and shows you its 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.
Working With oledb Adapter-.NET教程,数据库应用
this action adds one dataset derived class to your project. were not going in to details of this class.
Working With oledb Adapter-.NET教程,数据库应用
step 4: attach dataset with a dataview
now attach this dataset with a dataview. drag a dataview control from toolbox->data and set its table property to your datasets table.
Working With oledb Adapter-.NET教程,数据库应用
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.
Working With oledb Adapter-.NET教程,数据库应用
now fill the data from dataadapter to the dataset by calling dataadapters 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.
Working With oledb Adapter-.NET教程,数据库应用


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+. maheshs background includes masters 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…
赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » Working With oledb Adapter-.NET教程,数据库应用
分享到: 更多 (0)

相关推荐

  • 暂无文章