Use objectdatasource in Oracle to read a strongly-Typed Dataset

Source: Internet
Author: User

This blog post mainly describes how to use objectdatasource to read data in the. XSD dataset file,

The only difference from the past is that these data tables come from the oralce database, not the SQL Server database,

If you want to operate the Oracle database in Visual Studio and design the dataset. XSD in a visualized manner,

You must follow ODT. net, which is a plug-in developed by Oracle for Visual Studio,

The dataset file, that is, the. XSD file, is often used when SQL Server is used. This is very convenient,

It is also very simple and practical, but previously it was intended for SQL Server databases. For Oracle databases,

If you want to access in Visual Studio, you can only access it through ODBC or oledb,

To simplify development, Oracle cooperates with Microsoft to provide the ODT. Net Visual Studio plug-in,

With this plug-in, you can operate your Oracle Database in Visual Studio,

Let's just take a look at some content about the dataset,

The author's blog post "the first article on LINQ to dataset" and "the next article on the LINQ to dataset" give a detailed description of how to operate datasets,

However, these operations are for SQL Server operations. This blog post introduces these operations for Oracle databases,

If you do not know how to use the dataset. XSD, refer to the two blog posts of the author,

Let's first mention what is a dataset file?

This is a dataset file,

I will not introduce the dataset file too much here. If you are not familiar with it, please read the first two blog posts,

Next we will demonstrate how to use this dataset file to access the employee data table in the Oracle database,

Then bind an objectdatasource to the. XSD dataset file,

The last step is to set a gridview data source as objectdatasource to display data,

Since you want to access the Oracle database in Visual Studio, you still need to make some settings,

The environment must also have certain requirements,

First, you must install ODT. net,

You can download the version corresponding to your Oracle database and Visual Studio on the official Oracle website,

After installing ODT. net, you also need to establish a connection with the Oracle database in Visual Studio,

The above knowledge is also detailed in the previous blog posts. You only need to follow the instructions and then click OK,

If you still don't know, you don't have to worry about it. You can check it out,

Then the demo is started,

This demo does not need to write a server line.Code,

First, add a. ASPX page,

Then add a. XSD dataset file,

Then drag the employee data table to. XSD in the server resource manager,

In this way, even if your dataset file is successfully set, pay attention to the two names,

Employee and employeetableadapter

In fact, when you drag the data table in the Oracle database to the. XSD file,

Visual Studio will help you generate a lot of code,

Which will automatically generateEmployeetableadapterThis class

In fact, you canEmployeetableadapterAsSqldataadapter,

But thisEmployeetableadapterOnly applicableEmployeeThis data table is operated,

After completing the dataset design, be sure to regenerate the entire project,

In this way, the class to be constructed for your dataset is generated,

Then we design the page,

The page design is very simple. You can drag a gridview directly to the page,

Set the data source of the gridview to objectdatasource,

Next, configure the objectdatasource,

After this step,

Here we can see the class employeetableadapter generated by. XSD,

Select this class as the Business Object of objectdatasource,

After all the above configurations are complete, you can check the effect of the entire demo,

Now the entire demo has been completed. This demo is actually very simple,

I just changed it to accessing the Oracle database,

At the same time, I also want to demonstrate the powerful functions of the ODT. Net plug-in !!!

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.