9548086042 for call girls in Indira Nagar with room service
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