SlideShare uma empresa Scribd logo
1 de 4
Baixar para ler offline
Sybase ASE 15
with ASP.NET 2.0
By Anil Mahadev




Anil Mahadev provides the ISUG                 ybase continues to make significant     Software requirements
Technical Journal with a
‘QuickStart’ tutorial on web
                                       S       enhancements to its flagship enter-
                                               prise class database Adaptive Server
                                       Enterprise (ASE). The release of version
                                                                                       1) Windows 2000 and above.
                                                                                       2) A personal copy of SYBASE ASE 15
                                                                                           (Any edition will do, as we are devel-
application development with           15 in 2005 along with its subsequent sib-           oping for test purposes only, I will be
Sybase ASE 15 and ASP.NET 2.0          lings, 15.0.1 and 15.0.2, in later years has        using the Developer Edition of
                                       awoken the curiosity of more and more               SYBASE ASE 15 for Windows.)
                                       developers who are now taking ASE for a                You can download SYBASE ASE 15
                                       spin. Couple this with Sybase's commit-             from the Sybase website and try it out.
                                       ment to supporting additional develop-              It’s FREE for development purposes
                                       ment platforms, like .NET and J2EE in               only (not to be deployed in a produc-
                                       addition to Power Builder - and you can             tion environment) as specified by the
                                       see why this is an exciting time for us             license agreement. www.sybase.com/
                                       developers.                                         ase_1500devel
                                                                                       3) Microsoft Visual Studio.NET 2005
                                         What has changed?                                 (Professional or Team System) - you
                                         Sybase ASE and .NET have now become               can order a free Trial DVD from
                                         so much easier to use than the previous           Microsoft.
                                         releases – and Visual Studio 2005 promises    4) Install the SYBASE ASE 15 Data
                                         a whole lot of features that Sybase has           Provider for ADO.NET during the
                                         taken advantage of in its Data Window             installation of SYBASE ASE 15.
                                         .NET software. In this piece,                        We shall be using the pubs2 sample
                                             I am happy to share with you my               database and authors table. For those
                                         experience of using SYBASE ASE 15                 of you who do not have the pubs2
                                         with ASP.NET 2.0 within the Visual                database installed. Follow these steps
                                         Studio 2005 IDE – and I’m going to do             to install them on your ASE Server.
                                         so without writing a single line of code.         a) Open Interactive SQL and from
                                             In VS 2005 and ASP.NET 2.0, using                  the File Menu choose Run Script.
                                         ASE 15 has never been as good as it is            b) Navigate to your Sybase ASE
                                         now. In this first segment, I will take you            installation folder and drill down
                                         through building a data-driven website                 to the scripts folder.
                                         using Sybase ASE 15’s ADO.NET Data                c) Under that, filter by all files and
                                         Provider with ASP.NET 2.0. The goal of                 choose pubs2.
                                         the application is that it must display the       d) Now the database starts getting
Anil Mahadev is an experienced data- authors from the authors table, it must                    created for you – and you can view
base consultant and writer on database also perform sorting and pagination.                     it from within Sybase Central.
technologies with several years training     We are going to be using the Grid         Now that we have our database and tables
& consulting experience. He is           View Control for this – so here are the       ready, we can visually build applications in
available at anilm001@gmail.com          requirements for this tutorial.               Visual Studio 2005.

30    ISUG TECHNICAL JOURNAL
SYBASE ASE 15         WITH    A S P. N E T   2.0




Steps to building the application                             You can download SYBASE ASE 15 from the
Launch Visual Studio 2005. Click on File ➠ New Website.
Now you can choose the language and select from C# or VB      Sybase website and try it out. It’s FREE for
as shown in figure 1.
                                                              development purposes only and not to be

                                                              deployed in a production environment as

                                                              specified by the license agreement.




                                                                                                                                DESIGN & DEVELOPMENT
Figure 1

We now will be in the source view by default – so switch to
the Design View.
    Then you can add the following controls onto the page
and set their properties as indicated in the table below.
Control Name               Properties

Label Control              Building ASP.NET Apps with
                                                              Figure 2
                           Sybase ASE 15

GridView Control           None needed - only                 Our application should now look like figure 3.
                           configuration required.


We now have our controls in place so we need to perform one
more step before proceeding. We need to add a reference to
the ASE Data Provider Namespace Assembly.
a) Right click on the Project and choose Add reference.
    Now under the tabs, choose under the .NET tab you can
    see the Sybase.Data.AseClient or alternatively you can
    navigate to the Sybase ASE Installation folder
    x:SYBASEASE15DataAccessADONETdll
    where x is your drive in your own hard drive.
                                                              Figure 3
Next choose the Sybase.Data.AseClient.dll. Then click on
OK and your project now hosts the ASE for .NET Assembly       Configuring our Data Source
as shown below. The Sybase ASE .NET Client is registered as   We are now going to create a new connection to the ASE
a Native Assembly within the Windows operating system.        Server. Click on your Grid View Control and under Data
    This is shown in figure 2.                                Source choose New Data Source.




                                                                                                M AY- J U N E 2 0 0 8     31
SYBASE ASE 15           WITH    A S P. N E T   2.0




    Under Data Sources➠Data Source Configuration Wizard
choose create a new Connection. Now we will need to build a
new Sybase Data Source. Under the System DSN Tab, click
new and choose Adaptive Server Enterprise as the chosen
database server. Now you will be taken to a dialog where you
will need to specify an existing connection to a Sybase ASE
15 database.
    The connection dialog will be as shown in the figure 4.


                                                                      Figure 6

                                                                      Configuring the grid view
                                                                      You will need to choose the connection you have created to
                                                                      connect to Sybase ASE 15.
                                                                          Click next and give this ConnectionString a name, say,
                                                                      pubs2 - and then you have the option to re-use this connection
                                                                      string for multiple pages. Click ‘next’ as shown in figure 7.




Figure 4

Next you will need to test the connection. Once you get a             Figure 7
message that says Login Succeeded, it means that the connec-
tion to your server is now ready.                                     You will be asked to select a table from Sybase ASE 15. Since
    [Note: As a security measure ASE does not allow the user to       only the views are displayed, choose the ‘Specify a custom
enter the password directly. Instead the user is given an option to   SQL statement’ option and manually enter the SQL
enter the password in the next dialog once the user clicks on Test    Statement by clicking next as shown in figure 8.
Connection.]
    You will now get a message (as shown in figure 5) for
successful connection.

Figure 5

Reasons for connections not succeeding
1) Check your Server status ➠ Running.
2) Check the port numbers on your machines.
3) Verify the credentials.
   The Data Source name will be the connection parameter              Figure 8
that the GridView will take when connecting to your Sybase
ASE Database Server and displaying the contents onto your              We will now get a list of all the author details from the
WebForm.                                                              authors table. The query that we will be using is a simple
   The final screen that appears is shown in figure 6.                select statement. Select * from authors.

32     ISUG TECHNICAL JOURNAL
SYBASE ASE 15          WITH     A S P. N E T   2.0




                                                                  Problem: After configuring your data source, your password
                                                                  does not get saved in the web.config file.
                                                                  Resolution: Add the password as given below in your
                                                                  web.config file under the connection string setting.

                                                                     <connectionStrings>
                                                                     <add name="ConnectionString"
                                                                     connectionString="DSN=SybaseASE15;UID=your ase
                                                                     username;PWD=your ase password"
                                                                     providerName="System.Data.Odbc"/>
                                                                     </connectionStrings>

Figure 9
                                                                  After making the appropriate changes, we now have our Grid




                                                                                                                                       DESIGN & DEVELOPMENT
                                                                  View configured and we are ready to run the application.
                                                                     Our final application will appear as shown in figure 13.




Figure 10

At this point you have the option to customize your query by
clicking on the Query Builder button. We are not going to be
doing anything with our query so let’s move along. Click next
and in the last section let’s make sure that we get the desired   Figure 13
results – so click on the Test Query button. This is shown in
figure 10.                                                        You should be able to view the final application as shown
    Click Finish to complete the configuration.                   in the browser with page 1 and page 3 screens below.
    There can be times when a table consists of a thousand or         To demonstrate the sorting functionality click on the
more rows; it’s not advisable to load all the rows onto one       au_fname link and see how all author’s first names are
page, so therefore Pagination needs to be enabled for our Grid    alphabetized. This is shown in the figure 14.
View control. To enable Pagination, Sorting and Selection
click on the three checkboxes as shown in figure 11.
    Our Grid View is now ready. You may want to auto-format
your Grid View and Details View for clearer presentation.
    Now press F5 to run the application.




Figure 11                                                         Figure 14

You’ll now see a figure like the one shown below in figure 12.    Wow, now wasn’t that easy to work with Sybase ASE 15 using
                                                                  ASP.NET?
                                                                     There are more incredible things you can do; I’ll let you
                                                                  know about more options in forthcoming features and tutorials.
                                                                     Sybase is a great database platform - and you can leverage
                                                                  your existing skills from SQL Server to Sybase by following
                                                                  what is a very efficient learning curve. ■
Figure 12

                                                                                                      M AY- J U N E 2 0 0 8      33

Mais conteúdo relacionado

Mais procurados

Vmware tools-installation-configuration
Vmware tools-installation-configurationVmware tools-installation-configuration
Vmware tools-installation-configuration
Ram Prasad Ohnu
 
websphere commerce server admin configuration
websphere commerce server admin configuration websphere commerce server admin configuration
websphere commerce server admin configuration
Laxmi Kanth Kshatriya
 
Application lifecycle management in SharePoint
Application lifecycle management in SharePointApplication lifecycle management in SharePoint
Application lifecycle management in SharePoint
Jeremy Thake
 
OS-free server application delivery for instant provisioning
OS-free server application delivery for instant provisioningOS-free server application delivery for instant provisioning
OS-free server application delivery for instant provisioning
AppZero
 

Mais procurados (9)

BoxGrinder – FOSDEM 2012
BoxGrinder – FOSDEM 2012BoxGrinder – FOSDEM 2012
BoxGrinder – FOSDEM 2012
 
Office 365 ProPlus: Click-to-run deployment and management
Office 365 ProPlus: Click-to-run deployment and managementOffice 365 ProPlus: Click-to-run deployment and management
Office 365 ProPlus: Click-to-run deployment and management
 
Vmware tools-installation-configuration
Vmware tools-installation-configurationVmware tools-installation-configuration
Vmware tools-installation-configuration
 
websphere commerce server admin configuration
websphere commerce server admin configuration websphere commerce server admin configuration
websphere commerce server admin configuration
 
Application lifecycle management in SharePoint
Application lifecycle management in SharePointApplication lifecycle management in SharePoint
Application lifecycle management in SharePoint
 
Continuous Delivery with Grails and CloudBees
Continuous Delivery with Grails and CloudBeesContinuous Delivery with Grails and CloudBees
Continuous Delivery with Grails and CloudBees
 
Installing Websphere Portal in the IBM Smartcloud
Installing Websphere Portal in the IBM SmartcloudInstalling Websphere Portal in the IBM Smartcloud
Installing Websphere Portal in the IBM Smartcloud
 
OS-free server application delivery for instant provisioning
OS-free server application delivery for instant provisioningOS-free server application delivery for instant provisioning
OS-free server application delivery for instant provisioning
 
Don't Put Your WordPress Site at Risk
Don't Put Your WordPress Site at RiskDon't Put Your WordPress Site at Risk
Don't Put Your WordPress Site at Risk
 

Semelhante a Sybase and ASP.NET2.0 Article

nOOb-1.1-Dev-Env-pt-II.ppt
nOOb-1.1-Dev-Env-pt-II.pptnOOb-1.1-Dev-Env-pt-II.ppt
nOOb-1.1-Dev-Env-pt-II.ppt
webhostingguy
 
Part 4 working with databases
Part 4 working with databasesPart 4 working with databases
Part 4 working with databases
techbed
 

Semelhante a Sybase and ASP.NET2.0 Article (20)

nOOb-1.1-Dev-Env-pt-II.ppt
nOOb-1.1-Dev-Env-pt-II.pptnOOb-1.1-Dev-Env-pt-II.ppt
nOOb-1.1-Dev-Env-pt-II.ppt
 
Asp.net core tutorial
Asp.net core tutorialAsp.net core tutorial
Asp.net core tutorial
 
Deploy applications with TFS Build
Deploy applications with TFS BuildDeploy applications with TFS Build
Deploy applications with TFS Build
 
tutorials-visual-studio_visual-studio-2015-preview-comes-with-emulator-for-an...
tutorials-visual-studio_visual-studio-2015-preview-comes-with-emulator-for-an...tutorials-visual-studio_visual-studio-2015-preview-comes-with-emulator-for-an...
tutorials-visual-studio_visual-studio-2015-preview-comes-with-emulator-for-an...
 
Beginners introduction to asp.net
Beginners introduction to asp.netBeginners introduction to asp.net
Beginners introduction to asp.net
 
Asp dotnet net core
Asp dotnet net coreAsp dotnet net core
Asp dotnet net core
 
What's new in microsoft dynamics ax7
What's new in microsoft dynamics ax7What's new in microsoft dynamics ax7
What's new in microsoft dynamics ax7
 
Asp-net
 Asp-net Asp-net
Asp-net
 
Asp.Net Tutorials
Asp.Net TutorialsAsp.Net Tutorials
Asp.Net Tutorials
 
Cloud: Publish First Web Application to Azure Using Visual Studio
Cloud: Publish First Web Application to Azure Using Visual StudioCloud: Publish First Web Application to Azure Using Visual Studio
Cloud: Publish First Web Application to Azure Using Visual Studio
 
Asp.net Web Development.pdf
Asp.net Web Development.pdfAsp.net Web Development.pdf
Asp.net Web Development.pdf
 
Part 4 working with databases
Part 4 working with databasesPart 4 working with databases
Part 4 working with databases
 
Microsoft .NET 6 -What's All About The New Update
Microsoft .NET 6 -What's All About The New UpdateMicrosoft .NET 6 -What's All About The New Update
Microsoft .NET 6 -What's All About The New Update
 
Guide to Vite JS – Modern Fron-End Development Tool
Guide to Vite JS – Modern Fron-End Development ToolGuide to Vite JS – Modern Fron-End Development Tool
Guide to Vite JS – Modern Fron-End Development Tool
 
Install, configure and customize TFS 2013
Install, configure and customize TFS 2013Install, configure and customize TFS 2013
Install, configure and customize TFS 2013
 
Support of Visual Studio 2017 and Roslyn 2.0 in PVS-Studio: sometimes it's no...
Support of Visual Studio 2017 and Roslyn 2.0 in PVS-Studio: sometimes it's no...Support of Visual Studio 2017 and Roslyn 2.0 in PVS-Studio: sometimes it's no...
Support of Visual Studio 2017 and Roslyn 2.0 in PVS-Studio: sometimes it's no...
 
Visual studio 2017 - What's New
Visual studio 2017   - What's NewVisual studio 2017   - What's New
Visual studio 2017 - What's New
 
The Business Benefits of GitOps
The Business Benefits of GitOpsThe Business Benefits of GitOps
The Business Benefits of GitOps
 
1 app 2 developers 3 servers
1 app 2 developers 3 servers1 app 2 developers 3 servers
1 app 2 developers 3 servers
 
IBM z/OS Provisioning Toolkit v1.0.2
IBM z/OS Provisioning Toolkit v1.0.2IBM z/OS Provisioning Toolkit v1.0.2
IBM z/OS Provisioning Toolkit v1.0.2
 

Mais de ANIL MAHADEV

An introduction to_application_development_in_ibm_db2_udb_using_microsoft_vis...
An introduction to_application_development_in_ibm_db2_udb_using_microsoft_vis...An introduction to_application_development_in_ibm_db2_udb_using_microsoft_vis...
An introduction to_application_development_in_ibm_db2_udb_using_microsoft_vis...
ANIL MAHADEV
 

Mais de ANIL MAHADEV (8)

409-4973373
409-4973373409-4973373
409-4973373
 
Delphi developer certification study guide
Delphi developer certification study guideDelphi developer certification study guide
Delphi developer certification study guide
 
RAD Studio XE4 Product Reviewers Guide
RAD Studio XE4 Product Reviewers GuideRAD Studio XE4 Product Reviewers Guide
RAD Studio XE4 Product Reviewers Guide
 
ER/Studio XE3 DataSheet
ER/Studio XE3 DataSheetER/Studio XE3 DataSheet
ER/Studio XE3 DataSheet
 
DB PowerStudio XE DataSheet
DB PowerStudio XE DataSheetDB PowerStudio XE DataSheet
DB PowerStudio XE DataSheet
 
RAD Studio XE4 Data Sheet
RAD Studio XE4 Data SheetRAD Studio XE4 Data Sheet
RAD Studio XE4 Data Sheet
 
IBM DB2 App Development with Microsoft Visual C#
IBM DB2 App Development with Microsoft Visual C#IBM DB2 App Development with Microsoft Visual C#
IBM DB2 App Development with Microsoft Visual C#
 
An introduction to_application_development_in_ibm_db2_udb_using_microsoft_vis...
An introduction to_application_development_in_ibm_db2_udb_using_microsoft_vis...An introduction to_application_development_in_ibm_db2_udb_using_microsoft_vis...
An introduction to_application_development_in_ibm_db2_udb_using_microsoft_vis...
 

Último

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

Último (20)

Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 

Sybase and ASP.NET2.0 Article

  • 1. Sybase ASE 15 with ASP.NET 2.0 By Anil Mahadev Anil Mahadev provides the ISUG ybase continues to make significant Software requirements Technical Journal with a ‘QuickStart’ tutorial on web S enhancements to its flagship enter- prise class database Adaptive Server Enterprise (ASE). The release of version 1) Windows 2000 and above. 2) A personal copy of SYBASE ASE 15 (Any edition will do, as we are devel- application development with 15 in 2005 along with its subsequent sib- oping for test purposes only, I will be Sybase ASE 15 and ASP.NET 2.0 lings, 15.0.1 and 15.0.2, in later years has using the Developer Edition of awoken the curiosity of more and more SYBASE ASE 15 for Windows.) developers who are now taking ASE for a You can download SYBASE ASE 15 spin. Couple this with Sybase's commit- from the Sybase website and try it out. ment to supporting additional develop- It’s FREE for development purposes ment platforms, like .NET and J2EE in only (not to be deployed in a produc- addition to Power Builder - and you can tion environment) as specified by the see why this is an exciting time for us license agreement. www.sybase.com/ developers. ase_1500devel 3) Microsoft Visual Studio.NET 2005 What has changed? (Professional or Team System) - you Sybase ASE and .NET have now become can order a free Trial DVD from so much easier to use than the previous Microsoft. releases – and Visual Studio 2005 promises 4) Install the SYBASE ASE 15 Data a whole lot of features that Sybase has Provider for ADO.NET during the taken advantage of in its Data Window installation of SYBASE ASE 15. .NET software. In this piece, We shall be using the pubs2 sample I am happy to share with you my database and authors table. For those experience of using SYBASE ASE 15 of you who do not have the pubs2 with ASP.NET 2.0 within the Visual database installed. Follow these steps Studio 2005 IDE – and I’m going to do to install them on your ASE Server. so without writing a single line of code. a) Open Interactive SQL and from In VS 2005 and ASP.NET 2.0, using the File Menu choose Run Script. ASE 15 has never been as good as it is b) Navigate to your Sybase ASE now. In this first segment, I will take you installation folder and drill down through building a data-driven website to the scripts folder. using Sybase ASE 15’s ADO.NET Data c) Under that, filter by all files and Provider with ASP.NET 2.0. The goal of choose pubs2. the application is that it must display the d) Now the database starts getting Anil Mahadev is an experienced data- authors from the authors table, it must created for you – and you can view base consultant and writer on database also perform sorting and pagination. it from within Sybase Central. technologies with several years training We are going to be using the Grid Now that we have our database and tables & consulting experience. He is View Control for this – so here are the ready, we can visually build applications in available at anilm001@gmail.com requirements for this tutorial. Visual Studio 2005. 30 ISUG TECHNICAL JOURNAL
  • 2. SYBASE ASE 15 WITH A S P. N E T 2.0 Steps to building the application You can download SYBASE ASE 15 from the Launch Visual Studio 2005. Click on File ➠ New Website. Now you can choose the language and select from C# or VB Sybase website and try it out. It’s FREE for as shown in figure 1. development purposes only and not to be deployed in a production environment as specified by the license agreement. DESIGN & DEVELOPMENT Figure 1 We now will be in the source view by default – so switch to the Design View. Then you can add the following controls onto the page and set their properties as indicated in the table below. Control Name Properties Label Control Building ASP.NET Apps with Figure 2 Sybase ASE 15 GridView Control None needed - only Our application should now look like figure 3. configuration required. We now have our controls in place so we need to perform one more step before proceeding. We need to add a reference to the ASE Data Provider Namespace Assembly. a) Right click on the Project and choose Add reference. Now under the tabs, choose under the .NET tab you can see the Sybase.Data.AseClient or alternatively you can navigate to the Sybase ASE Installation folder x:SYBASEASE15DataAccessADONETdll where x is your drive in your own hard drive. Figure 3 Next choose the Sybase.Data.AseClient.dll. Then click on OK and your project now hosts the ASE for .NET Assembly Configuring our Data Source as shown below. The Sybase ASE .NET Client is registered as We are now going to create a new connection to the ASE a Native Assembly within the Windows operating system. Server. Click on your Grid View Control and under Data This is shown in figure 2. Source choose New Data Source. M AY- J U N E 2 0 0 8 31
  • 3. SYBASE ASE 15 WITH A S P. N E T 2.0 Under Data Sources➠Data Source Configuration Wizard choose create a new Connection. Now we will need to build a new Sybase Data Source. Under the System DSN Tab, click new and choose Adaptive Server Enterprise as the chosen database server. Now you will be taken to a dialog where you will need to specify an existing connection to a Sybase ASE 15 database. The connection dialog will be as shown in the figure 4. Figure 6 Configuring the grid view You will need to choose the connection you have created to connect to Sybase ASE 15. Click next and give this ConnectionString a name, say, pubs2 - and then you have the option to re-use this connection string for multiple pages. Click ‘next’ as shown in figure 7. Figure 4 Next you will need to test the connection. Once you get a Figure 7 message that says Login Succeeded, it means that the connec- tion to your server is now ready. You will be asked to select a table from Sybase ASE 15. Since [Note: As a security measure ASE does not allow the user to only the views are displayed, choose the ‘Specify a custom enter the password directly. Instead the user is given an option to SQL statement’ option and manually enter the SQL enter the password in the next dialog once the user clicks on Test Statement by clicking next as shown in figure 8. Connection.] You will now get a message (as shown in figure 5) for successful connection. Figure 5 Reasons for connections not succeeding 1) Check your Server status ➠ Running. 2) Check the port numbers on your machines. 3) Verify the credentials. The Data Source name will be the connection parameter Figure 8 that the GridView will take when connecting to your Sybase ASE Database Server and displaying the contents onto your We will now get a list of all the author details from the WebForm. authors table. The query that we will be using is a simple The final screen that appears is shown in figure 6. select statement. Select * from authors. 32 ISUG TECHNICAL JOURNAL
  • 4. SYBASE ASE 15 WITH A S P. N E T 2.0 Problem: After configuring your data source, your password does not get saved in the web.config file. Resolution: Add the password as given below in your web.config file under the connection string setting. <connectionStrings> <add name="ConnectionString" connectionString="DSN=SybaseASE15;UID=your ase username;PWD=your ase password" providerName="System.Data.Odbc"/> </connectionStrings> Figure 9 After making the appropriate changes, we now have our Grid DESIGN & DEVELOPMENT View configured and we are ready to run the application. Our final application will appear as shown in figure 13. Figure 10 At this point you have the option to customize your query by clicking on the Query Builder button. We are not going to be doing anything with our query so let’s move along. Click next and in the last section let’s make sure that we get the desired Figure 13 results – so click on the Test Query button. This is shown in figure 10. You should be able to view the final application as shown Click Finish to complete the configuration. in the browser with page 1 and page 3 screens below. There can be times when a table consists of a thousand or To demonstrate the sorting functionality click on the more rows; it’s not advisable to load all the rows onto one au_fname link and see how all author’s first names are page, so therefore Pagination needs to be enabled for our Grid alphabetized. This is shown in the figure 14. View control. To enable Pagination, Sorting and Selection click on the three checkboxes as shown in figure 11. Our Grid View is now ready. You may want to auto-format your Grid View and Details View for clearer presentation. Now press F5 to run the application. Figure 11 Figure 14 You’ll now see a figure like the one shown below in figure 12. Wow, now wasn’t that easy to work with Sybase ASE 15 using ASP.NET? There are more incredible things you can do; I’ll let you know about more options in forthcoming features and tutorials. Sybase is a great database platform - and you can leverage your existing skills from SQL Server to Sybase by following what is a very efficient learning curve. ■ Figure 12 M AY- J U N E 2 0 0 8 33