ASP's Date conversion constellation function

Source: Internet
Author: User
Tags date exit end split

After a long time to learn asp.netweb, so share with you, read this article you certainly have a lot of harvest, hope this article can teach you more things. When you learn asp.netweb, you may experience related problems, and here's how to solve the asp.netweb problem.

The structure is divided into three levels: the presentation layer, the business layer, and the data layer. Data tier: Represents the physical database. Business layer: Responsible for data transfer between the layer and presentation layer. Presentation layer: The client of an application that accesses the database through the business layer.

The presentation layer operates on local data that resides in memory and is implemented through the update methods provided by the business layer when database data needs to be updated. This can greatly improve the performance of your application, and when it is entirely up to you to update your data, you improve your programming flexibility.

Instance:

Here's a concrete example to see how to create a three-tier application with vb.net.

Database: We chose SQL Server's Northwind database. Business layer: We create a webservice as the middle tier. (Need to install IIS Service) Presentation layer: Asp.netweb We write a windowsform first step: Create WebService.

The specific steps are as follows:

1. Create a new project, select Asp.netweb Service, named: "Webservicefor Business Layer".

2. Add two SqlDataAdapter, one for Customer_da, pointing to the Customers table of the Northwind database, asp.netweb another to Order_da, to the Orders table for the Northwind database.

3. Then generate a TypedDataSet (choose "Data" menu, "Generate DataSet"), named: Super_ds.

4. The database connection is complete, and next we will consider the communication between it and the presentation layer, where we define two methods. One is: Get_dataset, which returns a Super_ds type DataSet and another: Update_dataset, which is responsible for updating the database data, the method code is as follows:

ImportsSystem.Web.Services PublicClassService1 InheritsSystem.Web.Services.WebService ' Webservicesdesignergeneratedcode ... <webmethod () >publicfunctionget_dataset () Assuper_ds Customer_da. Fill (SUPER_DS1. Customers) Order_da. Fill (SUPER_DS1. Orders) returnsuper_ds1 endfunction <webmethod () >publicsubupdate_dataset () super_ds1.  AcceptChanges () endsub webserviceexample Thehelloworld () Exampleservicereturnsthestringhelloworld.  Tobuild,uncommentthefollowinglinesthensaveandbuildtheproject.  Totestthiswebservice,ensurethatthe.asmxfileisthestartpage andpressF5. <webmethod () >publicfunctionhelloworld () asstring elloworld= "HelloWorld" endfunction endclass ' date conversion constellation function, parameter is date type
function Astro (birth)
Astro= ""
If birth= "" or not IsDate (birth) Then Exit function
Birthmonth=month (birth): If Birthmonth<10 then birthmonth= "0" & Birthmonth
Birthday=day (birth): If Birthday<10 then birthday= "0" & Birthday
Birth=trim (Birthmonth & Birthday) ' Reforming month, type 0903

Rastro=split ("Aquarius *0120*0219# Pisces *0220*0320# aries *0321*0420# taurus *0421*0521# gemini *0522*0621# Cancer *0622*0722# Leo *0723* 0823# Virgo *0824*0923# libra *0924*1023# Scorpio *1024*1122# Sagittarius *1123*1222# capricorn *1222*0119# "" # "

astro= "Capricorn" ' This is a cross year, bad contrast, the first default
For I_ls=0 to UBound (Rastro)-2
Rls2=split (Rastro (I_ls) & "*", "*")
If BIRTH>=RLS2 (1) and BIRTH<=RLS2 (2) Then
ASTRO=RLS2 (0)
Exit For
End If
Next
End Function



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.