November 13, 2009
@ 11:49 AM
I hope everyone in southern California is planning to attend this years SoCal Code Camp in San Diego on 11/21 - 11/22. It's always a great time and lots of free training!

I will be presenting the following sessions and I hope you will attend. Also, check out my new .NET discussion site called DotNet Army!

Building nTier Applications with Entity Framework Services

Learn how to build real world nTier applications with the new Entity Framework and related services introduced in .NET 3.5 SP1. With this new technology built into .NET, you can easily wrap an object model around your database and have all the data access automatically generated or use your own stored procedures and views. Then learn how to easily and securely expose your object model using WCF with just a few line of code using ADO.NET Data Services. The session will demonstrate how to create and consume these new technologies from the ground up. Lots of code!

Slides: Building nTier Applications with Entity Framework Services.pdf (2.88 MB)
Demo Code: EntityFramework.zip (859.84 KB)


dotNetDave's Favorite Programming Tools

This session will focus on my favorite Visual Studio add-ins and other tools that makes programming faster and easier. I will focus on tools that are either free or very affordable. Tool categories include Writing Better Code (easier, faster and correct the first time!), Code Helpers, Documentation (helper and creation), General Utilities and more. These tools are designed to impress your boss and get you home at a reasonable time. Packed full of demonstrations and very few PowerPoint slides! Licenses for some of the 3rd party products I will be demonstrating will be given away (over $1,100 worth), so be sure to attend and bring a business card!

Slides: dotNetDave's Favorite Programming Tools.pdf (1.82 MB)

Building Rich & Interactive Web Applications with ASP.NET AJAX

Learn how to build rich web application interfaces using ASP.NET AJAX and the ASP.NET AJAX Control Toolkit. This new technology makes programming JavaScript into your ASP.NET pages easy, increasing the power and functionality of your applications, reducing round trips to the server, and making it easy to consume web services for dynamic content. In this session you will be introduced to the new client and server controls for ASP.NET and Java Script to learn how to build a rich Web 2.0 experience for your users.

Slides: Building Rich & Interactive Web Applications with ASP.NET AJAX - 2009.pdf (2.36 MB)
Demo Code: AdventureWorksAjax.zip (803.65 KB)

Why You Need .NET Coding Standards (2009)

This session will guide any level of programmer to greater productivity by providing the information needed to write consistent, maintainable code. Learn about project setup, assembly layout, code style, defensive programming and much, much more. We will even go over some real in production code and see what the programmer did wrong in "What's Wrong With this Code?". Code tips are included to help you write better, error free applications. Lots of code examples in C# and VB.NET.

Slides: Why You Need .NET Coding Standards-2009.pdf (3.8 MB)
Demo Code: CodingStandards.zip (245.54 KB)


Pictures and Video

SoCal CodeCamp Fullerton - 2009

Pictures & Video from This Years Code Camp:

Pictures from past SoCal Code Camps:

Video from past Code Camps:


 
Categories: ADO.NET | AJAX | ASP.NET | Code Camp | Csharp | Defensive Programming | Development | dotNetDave | Entity Framework | Generics | LINQ | VB.NET | VS.NET | WCF

ADO.NET Data Services v1.5 CTP2 is now available for download! This release (v1.5) targets the .NET Framework 3.5 SP1 & Silverlight 3 platforms and provides new client and server side features for data service developers. 

What’s included in CTP2?

This release includes updates to the features that were in the CTP1 release of ADO.NET Data Services v1.5 plus a few additional new features and a number of bug fixes including:

  • Projections
  • Data Binding updates
  • Feed Customization (aka "Web Friendly Feeds") updates
  • Server Driven Paging (SDP) client library support
  • Enhanced BLOB Support client library support
  • Request Pipeline
  • "Data Service Provider" Interface updates
For more information and to watch the Getting Started video check out the ADO.NET Data Services Team Blog.


 
Categories: ADO.NET | Entity Framework | WCF

I hope everyone in Arizona and southern California is planning to attend this years Desert Code Camp on 6/13 and SoCal Code Camp in San Diego on 6/27 - 6/28. It's always a great time and lots of free training! I will also be selling a limited number of my latest book "David McCarter's .NET Coding Standards" at my sessions for $12, cheaper than the web site (no tax and shipping), please bring exact change or check.

I will be presenting the following sessions and I hope you will attend. Also, check out my new .NET discussion site called DotNet Army!

Building nTier Applications with Entity Framework Services

Learn how to build real world nTier applications with the new Entity Framework and related services introduced in .NET 3.5 SP1. With this new technology built into .NET, you can easily wrap an object model around your database and have all the data access automatically generated or use your own stored procedures and views. Then learn how to easily and securely expose your object model using WCF with just a few line of code using ADO.NET Data Services. The session will demonstrate how to create and consume these new technologies from the ground up. Lots of code!

Slides: Building nTier Applications with Entity Framework Services.pdf (2.88 MB)
Demo Code: EntityFramework.zip (859.84 KB)


dotNetDave's Favorite Programming Tools

This session will focus on my favorite Visual Studio add-ins and other tools that makes programming faster and easier. I will focus on tools that are either free or very affordable. Tool categories include Writing Better Code (easier, faster and correct the first time!), Code Helpers, Documentation (helper and creation), General Utilities and more. These tools are designed to impress your boss and get you home at a reasonable time. Packed full of demonstrations and very few PowerPoint slides! Licenses for some of the 3rd party products I will be demonstrating will be given away, so be sure to attend and bring a business card!

Slides: dotNetDave's Favorite Programming Tools.pdf (1.82 MB)

Building Rich & Interactive Web Applications with ASP.NET AJAX

Learn how to build rich web application interfaces using ASP.NET AJAX and the ASP.NET AJAX Control Toolkit. This new technology makes programming JavaScript into your ASP.NET pages easy, increasing the power and functionality of your applications, reducing round trips to the server, and making it easy to consume web services for dynamic content. In this session you will be introduced to the new client and server controls for ASP.NET and Java Script to learn how to build a rich Web 2.0 experience for your users.

Slides: Building Rich & Interactive Web Applications with ASP.NET AJAX - 2009.pdf (2.36 MB)
Demo Code: AdventureWorksAjax.zip (803.65 KB)

Why You Need .NET Coding Standards (2009)

This session will guide any level of programmer to greater productivity by providing the information needed to write consistent, maintainable code. Learn about project setup, assembly layout, code style, defensive programming and much, much more. We will even go over some real in production code and see what the programmer did wrong in "What's Wrong With this Code?". Code tips are included to help you write better, error free applications. Lots of code examples in C# and VB.NET.

Slides: Why You Need .NET Coding Standards-2009.pdf (3.8 MB)
Demo Code: CodingStandards.zip (245.54 KB)


Pictures and Video

SoCal CodeCamp Fullerton - 2009

Pictures from This Years Code Camp:

Pictures from past SoCal Code Camps:

Video from past Code Camps:


 
Categories: .NET | ADO.NET | AJAX | ASP.NET | C# | Code Camp | Defensive Programming | dotNetDave | Entity Framework | Generics | LINQ | VB.NET | VS.NET | WCF | Web Services

May 21, 2009
@ 02:53 PM

As you might know I'm really picky when it comes to formatting code... heck, I event wrote a book on it! This even extends to T-SQL. I have worked at companies that had stored procedures that were formatted so poorly that I could not follow it at all. Thankfully I found a very cool web site called Instant SQL Formatter that does all the work for me... instantally! It will format T-SQL like this (generated by SQL Server Management Studio):

USE [Acme]
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].EventLog_DeleteOld') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].EventLog_DeleteOld
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].EventLog_DeleteOld
AS
BEGIN
 DELETE FROM EventLog WHERE ([TimeStamp] < GETDATE() - 14)
END
GO

To this:

USE [Acme]

GO

IF EXISTS (SELECT *
           FROM   sys.objects
           WHERE  object_id = Object_id(N'[dbo].EventLog_DeleteOld')
                  AND TYPE IN (N'P',N'PC'))
  DROP PROCEDURE [dbo].eventlog_deleteold

GO

SET ansi_nulls  ON

GO

SET quoted_identifier  ON

GO

CREATE PROCEDURE [dbo].Eventlog_deleteold
AS
  BEGIN
    DELETE FROM eventlog
    WHERE       ([TimeStamp] < Getdate() - 14)
  END

GO

Very nice! There are lots of options (the T-SQL was formatted with just the defaults).

Tip Submitted By: David McCarter


 
Categories: ADO.NET | Link | SQL Server

January 9, 2009
@ 03:19 PM
I hope everyone in southern California is planning to attend this years SoCal Code Camp at Cal State Fullerton on 1/24 - 1/25. It's always a great time and lots of free training! I will also be selling a limited number of my latest book "David McCarter's .NET Coding Standards" at my sessions for $11, cheaper than the web site (no tax and shipping), please bring exact change.

I will be presenting the following sessions and I hope you will attend. Also, check out my new .NET discussion site called DotNet Army!

Building nTier Applications with Entity Framework Services

1:30PM Saturday - Room: UH 246

Learn how to build real world nTier applications with the new Entity Framework and related services introduced in .NET 3.5 SP1. With this new technology built into .NET, you can easily wrap an object model around your database and have all the data access automatically generated or use your own stored procedures and views. Then learn how to easily and securely expose your object model using WCF with just a few line of code using ADO.NET Data Services. The session will demonstrate how to create and consume these new technologies from the ground up. Lots of code!

Slides: Building nTier Applications with Entity Framework Services.pdf (2.79 MB)
Demo Code: Building nTier Applications with Entity Framework Services.zip (849.73 KB)


dotNetDave's Favorite Programming Tools

1:15PM Saturday - Room: UH 250

This session will focus on my favorite Visual Studio add-ins and other tools that makes programming faster and easier. I will focus on tools that are either free or very affordable. Tool categories include Writing Code (easier, faster and correct the first time!), Code Helpers, Documentation (helper and creation), General Utilities and more. These tools are designed to impress your boss and get you home at a reasonable time. Packed full of demonstrations and very few PowerPoint slides! Licenses for some of the 3rd party products I will be demonstrating will be given away, so be sure to attend and bring a business card!

Slides: dotNetDave's Favorite Programming Tools.pdf (1.8 MB)

Building Rich & Interactive Web Applications with ASP.NET AJAX

11:30AM Saturday - Room: MH 121

Learn how to build rich web application interfaces using ASP.NET AJAX and the ASP.NET AJAX Control Toolkit. This new technology makes programming JavaScript into your ASP.NET pages easy, increasing the power and functionality of your applications, reducing round trips to the server, and making it easy to consume web services for dynamic content. In this session you will be introduced to the new client and server controls for ASP.NET and Java Script to learn how to build a rich Web 2.0 experience for your users.

Slides: Building Rich & Interactive Web Applications with ASP.NET AJAX - 2009.pdf (2.36 MB)
Demo Code: Building Rich & Interactive Web Applications with ASP.NET AJAX - 20091.zip (702.2 KB) UPDATED!

Why You Need .NET Coding Standards (2009)

2:30PM Saturday - Room: UH 250

This session will guide any level of programmer to greater productivity by providing the information needed to write consistent, maintainable code. Learn about project setup, assembly layout, code style, defensive programming and much, much more. We will even go over some real in production code and see what the programmer did wrong in "What's Wrong With this Code?". Code tips are included to help you write better, error free applications. Lots of code examples in C# and VB.NET.

Slides: Why You Need .NET Coding Standards-2009.pdf (3.46 MB)
Demo Code: Why You Need .NET Coding Standards-2009.zip (94.46 KB)


Pictures and Video

SoCal CodeCamp Fullerton - 2009

Pictures from This Years Code Camp:

Pictures from past SoCal Code Camps:

Video from past Code Camps:


 

Two new technologies, the Entity Framework (EF) and ADO.NET Data Services were released with .NET 3.5 SP1 in August 2008. These two major editions to the framework finally provide true data modeling and an easy way to send the data across a WCF service. Making programming the data tier much easier (kind of). Since these technologies are so new there is not a lot of good information out there and a lot of what you can find is a lot of "fluff"... not much "real world" solutions. Since I have been actively been using this where I work since it came out in a "real" project, I thought I would share what I have learned. This will be a living blog post, meaning that as I find things I will update it. So check back often.

One thing I should mention is that the project I am working on is converting VB6 code to C#. We use SQL Server 2005 with most all of the data access going through stored procedures. Most of the sp's I have seen so far are simple selects and inserts or selects based on a parameter. So these are ideal candidates for just letting the EF create the SQL dynamically.

Entity Framework

Design Considerations

When starting this project I chose to create an assembly just for the Entity Data Model's. This way, down the road it could easily be shared with another applications. I chose the naming scheme for the assembly of: MyCompay.Project.Data.Entities.dll (of course replace "MyCompany" and "Project" with your company name and project name). This works great since by default entity type access is public.

There is one caveat with this, when you configure your entities, connections are created in the app.config file that look like this:

<configuration>

  <connectionStrings><add name="MyEntities" connectionString="metadata=res://*/MyModel.csdl|res://*/MyModel.ssdl|res://*/MyModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=MyServer;Initial Catalog=MyApplicationDB;Integrated Security=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" /></connectionStrings>

</configuration>

This issue is when you reference this assembly in your WCF project (see more below), you will need to move the connection strings information to the web.config file under the <system.web> section.

Creating Your Entity Data Model

When I first started going though the VB6 project, I searched for sp calls or dynamic sql. As I saw these statements I added the appropriate tables to my data model. This worked great until I found the last table that was actually "root" table for the application. For example a Customer table that has a primary key that most if not all other tables rely on. While the designer correctly created the relationships, they never seemed to work correctly. I kept getting errors. So always add the "root" table first when creating your data model.

ADO.NET Data Services

Design Considerations

With the project I'm working on, there are multiple assemblies that will end up needing to connect to the Data Service to retrieve data. Because of this and the need to pass around the same "proxy" object, I decided to wrap the Data Service proxy in a separate assembly. The naming scheme I used for the assembly is: MyCompay.MyProduct.Data.ServiceProxy.dll  (of course replace "MyCompany" and "Project" with your company name and project name). By default the proxy object created to the Data Service is public so it's easily used by any other assembly. Also, configuration is easy since the location of the service is defined in one place in this assemblies app.config file.

LINQ

With the Data Services, LINQ can be used to call the service. This is great for the programmer since there is no need to master REST. Your LINQ statement will be automagically turned into REST. But be forewarned that at this point LINQ does not support all of REST. So you can write your LINQ statement, it will seem correct, but nothing will come back from the service. Most of the time there will be no warning or Exception either. So, if you are not getting data back, look at your LINQ query.

Loading Data

Retrieving data from a data service using LINQ is really simple. In my class I declare:

MyEntities _serviceProxy = new MyEntities();

Client _client;

Then to load, simply do the following LINQ statement:

_client = (from cl in _serviceProxy.Clients where cl.ClientId == this.ClientId select cl).Single<Client>();

This performs a call to the Data Service and returns a single Client object using a REST query simular to this:

http://localhost:4437/Services/MyDataService.svc/Clients('1')

To load child objects simply code the following:

_serviceProxy.LoadProperty(_client, "Accounts");

 

_serviceProxy.LoadProperty(_client, "Categories");

Each of the LoadProperty methods above will create a call to the Data Service. These calls can be batched to reduce network traffic, but you will basically have to write the REST queries manually... something I have not tackled yet.

Data Joins

Joins are not supported in Data Services because they are not supported in REST. But if you need to join data to display it in a grid etc, you can do it like you would do it in EF. For it to work the data will have to be preloaded into memory from the Data Service. The join would look similar to this:

var data = (from a in _client.Accounts

            join ac in _client.Categories on a.CatagoryId equals ac.Id into cat

            from c in cat.DefaultIfEmpty()

            orderby a.Type, a.Number

            select new

            {

                a.Id,

                a.Department,

                a.Number,

                a.Description,

                a.Type,

                a.IsTaxable,

                a.IsActive,

                Code = c == null ? string.Empty : c.Code

            }).Distinct();

 

accountGridView.DataSource = data.ToArray();

In the code above, cat.DefaultIfEmpty() is very important because if there is no match between Account and Category, then no data at all will be returned! Then in the last line of the select, it's also important to check for null, since "c" could be null and will throw an exception if you try to access one of its properties.

Now that you have your data into the grid control (DataGridView) you are going to run into another problem... retrieving the data from the DataSource! Since the data has been loaded as an anonymous type it can't be converted back. Also, since I chose not to show the Id property in the grid, I simply can not look at the first column.

So in my case, I only want the Id value of the row the user clicked on, from there I can use LINQ to look up the Account and what ever else I need to display more detailed data etc. For this we are going to have to use reflection.

private void accountGridView_SelectionChanged(object sender, EventArgs e)

{

     var data = accountGridView.Rows[accountGridView.SelectedRows[0].Index].DataBoundItem;

     var propInfo = data.GetType().GetProperty("Id");

     var propValue = (Int32)propInfo.GetValue(data, null);

 

     LoadAccountDetail((from acc in _client.Accounts where acc.Id == propValue select acc).Single());

}

As you can see in the code above we are using reflection and GetProperty to retrieve the value for Id from the grid DataBoundItem which I then use in the LINQ statement to retrieve the Account object.

Updating Data

One of the great things about the Entity Framework is the built in state tracking. This make is really simple to update, insert and delete object (data) with a single method call. Unfortunately, as soon as you serialize an EF object across the wire using any service including ADO.NET Data Service, this tracking is gone for the most part. Though Microsoft has promised to make this better in upcoming releases, for now we have to do it a little more manually, but still is pretty easy. You just need to remember this when using objects coming from a Data Service.

To update an object, simply change it's properties and then do the following:

_serviceProxy.UpdateObject(currentAccount);

 

_serviceProxy.SaveChanges();

Calling SaveChanges will make a call to the DataService. You can make as many calls to UpdateObject, AddObject and DeleteObject as needed before the SaveChanges call.

Service Methods

What's Not Supported
  • Enum parameters: I wanted to do this to send back different data based on an enum parameter (just like I do in normal programming). This is a perfect job for service methods. Unfortunately, I was told by Microsoft that it's not supported in "this release". They did not indicate if it will be supported in a future release.

"Good" Resources


 
Categories: ADO.NET | Csharp | Entity Framework | LINQ | WCF

If you are coming to the San Diego .NET Developers Group meeting tonight I hope you will be their early for my talk titled "What’s New In VS 2008 SP1". Lots of new additions to this SP, not just bug fixes. Below is a link to the presentation.

VS2008Sp1.pdf (715.88 KB)
 
Categories: .NET | ADO.NET | AJAX | ASP.NET | Csharp | dotNetDave | Entity Framework | LINQ | MVC | Silverlight | VB.NET | VS.NET | WCF | WinForms | WPF

Everyone should check this out. Lots of info on the new version:


http://go.microsoft.com/?linkid=9369515


The .NET Framework 3.5 Enhancements Training Kit includes presentations,
hands-on labs, demos, and event materials.


 
Categories: .NET | ADO.NET | Entity Framework | LINQ | MVC | News

March 10, 2008
@ 08:38 AM

The ASP.NET 3.5 Extensions Preview is a preview of new features being added to ASP.NET 3.5 and ADO.NET.

http://www.microsoft.com/downloads/details.aspx?FamilyID=A9C6BC06-B894-4B11-8300-35BD2F8FC908&displaylang=en


 
Categories: ADO.NET | AJAX | ASP.NET | Link

SQL Server Compact 3.5 is a small footprint in-process database engine that allows developers to build robust applications for Windows Desktops and Mobile Devices. This download contains the Books Online and Samples for SQL Server Compact 3.5
 

 
Categories: ADO.NET | Compact Framework | Link

I found out the hard way in the last two days that an SQL Server CE database does not work properly when creating a typed Dataset with a ASP.NET 3.5 application. Sure, you can create one in the IDE, but the code-on-the-fly will not be generated therefor you can't use it in your code. Actually causes an error if you try to build.

Rec'd an confirmation from Microsoft today that they did not implement this for ASP.NET. Just wanted to warn you so you don't waste an hour plus like I did. If you still want to use SQL Server CE and typed DataSets in ASP.NET you will need to create a separate assembly (which should be done anyway). Oh, won't work with LINQ either.


 
Categories: ADO.NET | ASP.NET | Compact Framework | SQL Server | LINQ

Sometimes you need to find all stored procedures in all databases in SQL Server that contain certain text. For example, today I had to find if any of our store procedures were connecting to other database servers via an IP address. I found the stored procedure below on the web and it works great.

-- exec sp_SearchText 
CREATE PROC SP_SEARCHTEXT
    @search NVARCHAR(1000)
AS
CREATE TABLE #RESULTS ( 
    [DATABASE] NVARCHAR(128),
    [SCHEMA] NVARCHAR(128),
    [NAME] NVARCHAR(128),
    [TYPE] NVARCHAR(20),
    [CREATED] DATETIME,
    [MODIFIED] DATETIME
)
DECLARE @db NVARCHAR(128) 
DECLARE @sql NVARCHAR(1000)
DECLARE CURDATABASES CURSOR FOR 
    SELECT DISTINCT NAME FROM MASTER..SYSDATABASES
OPEN CURDATABASES 
FETCH NEXT FROM CURDATABASES INTO @db
WHILE @@FETCH_STATUS = 0
    BEGIN
        SET @sql = ' insert into #results select  ROUTINE_CATALOG [Database], ROUTINE_SCHEMA [Schema],
                     ROUTINE_NAME [Name], ROUTINE_TYPE [Type], CREATED [Created], 
                     LAST_ALTERED [Altered] from  ['+ @db +'].INFORMATION_SCHEMA.ROUTINES 
                     where ROUTINE_DEFINITION like N''%' + @search + '%'' ' 
        EXEC(@sql) 
        FETCH NEXT FROM CURDATABASES INTO @db 
    END
CLOSE CURDATABASES
DEALLOCATE CURDATABASES
SELECT * FROM #RESULTS 
GO 

To use, run the stored procedure in the master database and then searching like this:

sp_SearchText '10.0.0'

Tip Submitted By: David McCarter


 
Categories: ADO.NET

SQL Server Database Publishing Wizard enables the deployment of SQL Server databases into a hosted environment on either a SQL Server 2000 or 2005 server. It generates a single SQL script file which can be used to recreate a database (both schema and data) in a shared hosting environment where the only connectivity to a server is through a web-based control panel with a script execution window. If supported by the hosting service provider, the Database Publishing Wizard can also directly upload databases to servers located at the shared hosting provider.

Optionally, SQL Server Database Publishing Wizard can integrate directly into Visual Studio 2005 and/or Visual Web Developer 2005 allowing easy publishing of databases from within the development environment.

Download by going to: http://www.microsoft.com/downloads/details.aspx?familyid=56E5B1C5-BF17-42E0-A410-371A838E570A&displaylang=en


 
Categories: ADO.NET | Link | News

Overview
SQLH2 collects four main types of information:
1. Feature Usage – What services/features are installed, running and level of workload on the service.
2. Configuration Settings – Machine, OS and SQL configuration settings, SQL instance and database metadata.
3. Uptime of the SQL Server service
4. Performance Counters (optional) – Used to determine performance trends

To download go to: http://www.microsoft.com/downloads/details.aspx?familyid=eedd10d6-75f7-4763-86de-d2347b8b5f89&displaylang=en


 
Categories: ADO.NET

Overloading Methods Must Be New To Oracle!

After loosing almost two days of work after getting the following error, I found what the real issue was.

ORA-06502: PL/SQL: numeric or value error: character string buffer too small

The issue is being the code optimizer that I am, I wrote the following line of code to create an out parameter:

OracleParameter parameterModuleID = new OracleParameter("@o_someoutdata", OracleDbType.Int32, 4, ParameterDirection.Output);

I based this decision on the intellisense I got from the Oracle object below:

As you can see, the third parameter is the length of the parameters. This is very important for out parameters because it sets up a buffer. After almost two days of not understanding why the stored procedure was not working, checking and rechecking the parameters lengths about ten times and banging my head against the desk… I found the problem.

Enter the genius of Oracle method overloading:

As you can see, the third parameter is defined as object and is actually the value of the parameter! WHAT? Doesn’t Oracle know that every type is basically an object in .NET and they have screwed this up? What morons!

The Solution

Go back to SQL Server! Well, if you cannot do that, the Microsoft Oracle namespace does not suffer from this stupid mistake, only the namespace from Oracle. The other solution is just to define the parameter on two lines:

OracleParameter parameterModuleID = new OracleParameter("@o_ someoutdata", OracleDbType.Int32, 4);
parameterModuleID.Direction = ParameterDirection.Output;

Alternatively, just use this overloaded method:

OracleParameter parameterModuleID = new OracleParameter("@o_someoutdata", OracleDbType.Int32, 4,
DBNull.Value, ParameterDirection.Output);

The forth parameter “null” is the value of the parameter. Have fun!

Lockup’s Rule My Life Now

Another thing I have noticed is that my computer locks up three or more times a day now since I have started to use the Oracle namespace! For some reason I am suspecting that it is pegging out the CPU via the aspnet_wp.exe process. I am converting an ASP.NET portal application from SQL Server to Oracle. This did not start happening until I started to implement the Oracle code. It is not just me! The two other people where I work using the Oracle namespace are having the same issue.

 

Order DOES Matter?

Here is a gotcha, when adding parameters to the command object with the Oracle namespace, they must be in the same order as defined in the stored procedure!?!? Get just one out of order and you will not get back the expected results. What is the point in naming the parameters then? SQL Server does not work this way, you can send in the parameters any way that you want... as long as they are all there and named correctly.

 

Oracle Stored Procedures are Impotent

Stored procedure names in Oracle can only be 30 characters long while SQL Server allows for 128 characters. I hope to never see a stored procedure 128 characters in length, but 30 characters is way too short to name many stored procedures descriptively and easy to read (no abbreviations)!

 

Me No Like GUID’s

When the SQL Server database we are using was converted to Oracle, a few tables had a column in it with a GUID (not used as a unique identifier) type (uniqueidentifier in SQL Server). Well, come to find out Oracle does not have any knowledge of GUID’s, so on the Oracle side the data type of those columns were changed to RAW. While this holds the GUID just fine, using the GUID is not so easy.

When I get the data out as a DataSet, it looks like this (when I output my DataSet as xml):

<SOMEGUID>+FTyMzclhkSpHehUTUByAA==</SOMEGUID>

It should really look like this:

<SOMEGUID>CE55A821-2449-4903-BA1A-EC16DB93F8DB</SOMEGUID>

As you can see, the GUID from Oracle is useless. What to do? Well, not knowing how this can be fixed on the Oracle side (no one else where I worked seemed to know either), I wrote nifty little method that will fix a table.

public static void ConvertGuidColumns(DataTable data, params string[] columnNames)
{
  foreach (DataRow row in data.Rows)
  {
   foreach(string columnName in columnNames)
   {
    try
    {
     row[columnName] = new Guid((byte[])row[columnName]);
    }
    catch
{}
   }
  }
}

This simply takes in a DataTable and a list of column names. Loops though the rows and converts any column from the Oracle RAW (really a Byte array) to a GUID .NET can use.

You need to also watch out when saving GUID’s to the database via a stored procedure. This won’t work:

OracleParameter parameterGUID = new OracleParameter("@I_SOMEGUID", OracleDbType.Raw);
parameterGUID.Value = someGUID;

This will:

OracleParameter parameterGUID = new OracleParameter("@I_SOMEGUID", OracleDbType.Raw);
parameterGUID.Value = someGUID.ToByteArray();

 

Tip By: David McCarter


 
Categories: ADO.NET

SP1 includes a variety of improvements to the inital product release. Documentation for this release is provided in the SP1readme_lang.htm file which can be downloaded below or found in the Reporting Services installation directory after Setup is complete.

  • To view a list of the bug fixes in SP1, see Microsoft Knowledge Base article 839796.
  • Late-breaking information that was not available in time to be included in this readme file will be published on the Microsoft Product Support Services Web site in Microsoft Knowledge Base article 843369.
  • To get the complete set of installation instructions, see Microsoft Knowledge Base article 842857.

For the complete article, go to: http://www.microsoft.com/downloads/details.aspx?familyid=580febf7-2972-40e7-bccf-6cd90ac2f464&displaylang=en


 
Categories: ADO.NET | News

The MDAC 2.8 SDK is for developers who are building applications using ADO, OLE DB, and ODBC. It contains updated documentation, headers, libs and typelibs for x86, IA64 and AMD64 platforms, as well as updated sample applications and developer tools.

The MDAC 2.8 SDK is designed for use with MDAC 2.8, which is also available for download from the Microsoft Download Center.

http://www.microsoft.com/downloads/details.aspx?familyid=5067faf8-0db4-429a-b502-de4329c8c850&displaylang=en


 
Categories: ADO.NET | News

If so, the Microsoft® Data Access Application Block for .NET is for you.

The Data Access Application Block encapsulates performance and resource management best practices for accessing Microsoft SQL Server™ databases. It can easily be used as a building block in your own .NET-based application. If you use it, you will reduce the amount of custom code you need to create, test, and maintain.

http://www.microsoft.com/downloads/details.aspx?familyid=f63d1f0a-9877-4a7b-88ec-0426b48df275&displaylang=en


 
Categories: ADO.NET | News

Using its built-in features, you can do the following from Microsoft Internet Explorer or your favorite Web browser:

  • Create and edit databases in SQL Server 2000 or Microsoft SQL Server 2000 Desktop Engine (MSDE 2000)
  • Perform ad-hoc queries against databases and save them to your file system
  • Export and import database schema and data
  • Manage users and roles
  • View, create and edit stored procedures

Whether you are doing Microsoft Windows or Web development, or just need remote access to data for yourself or your clients, the Web Data Administrator is the perfect complement to your toolbox.

 

http://www.microsoft.com/downloads/details.aspx?familyid=c039a798-c57a-419e-acbc-2a332cb7f959&displaylang=en


 
Categories: ADO.NET

REDMOND, Wash. -- Jan. 27, 2004 -- Microsoft Corp. today announced the availability of SQL Server (TM) 2000 Reporting Services. Reporting Services provides companies with a powerful new reporting tool that can increase business insight by providing real-time information from any data source to any device. As a result, employees at every level will have better access to information that will increase their ability to make more-informed decisions and provide more business value to their company. With the addition of Reporting Services, SQL Server, a part of the Microsoft® Windows Server System (TM) , provides the single most comprehensive data management and business intelligence (BI) platform on the market, with integrated analytics that include online analytical processing; data mining; data warehousing; extract, transform and load tools; and reporting functionality. This integrated, end-to-end approach helps companies make better decisions faster while lowering their total cost of ownership.

"Reporting Services is an enterprise-level reporting solution that is more affordable than competitive solutions in the marketplace today. It builds on the success of SQL Server 2000 to provide an integrated and scalable solution whether it is used to send interactive reports to five or 50,000 subscribers," said Paul Flessner, senior vice president of Enterprise Servers at Microsoft. "With Reporting Services, our customers benefit from a cost-effective, easy-to-use reporting solution that enables them to better leverage data from their disparate systems for smarter business decisions."

Industry Acclaims Microsoft's Comprehensive, Cost-Effective BI Offering

SQL Server 2000 offers a broad business intelligence platform that helps enable customers and partners to easily build custom business intelligence applications. This flexibility and interoperability provide users with powerful business intelligence solutions tailored to their specific needs. Customers such as ASB Bank Ltd., Best Buy Company Inc., Coldwater Creek Inc., Cox Communications Inc., IS Partners Co., Long & Foster Companies, Mary Kay Inc., PREMIER Bankcard, RF Micro Devices Inc., Scout-Master and TSYS have already started to implement Reporting Services solutions.

"In six short weeks, Reporting Services helped PREMIER Bankcard develop an enterprisewide business intelligence reporting solution that will result in a workload reduction equivalent of at least three full-time employees, giving those employees time to work on other, more-proactive projects," said Dan Zerfas, vice president of application development at PREMIER Bankcard. "Reporting Services is the perfect combination of flexibility, scalability and performance required to support the high-growth rate that we have been enjoying. With just 40 report authors across three business units, we look to deliver 400 BI reports to 500 users at all levels."

Reporting Services provides an open and extensible reporting platform industry partners can use to broaden their offerings without investing in building reporting infrastructure. Microsoft is collaborating with companies including ActiveViews Inc., Aspirity LLC, Comprehensive Software Systems, Configuresoft, Fenestrae, Geac Computer Corporation Ltd., Hitachi Consulting Corp., IntelligentApps Ltd., Intellinet Corp., OutlookSoft Corp., MaxQ Technologies Inc., MIS AG, Professional Advantage, ProClarity Corp., Solutions Consulting Group, Silvon Software Inc., SPSS Inc., Trax Retail Solutions Inc. and Unisys.

Industry analysts have also expressed high expectations for the value Reporting Services will bring to customers and partners. According to Giga Information Group analysts Philip Russom and Keith Gile, Reporting Services has the potential to reshape the niche market for reporting, just as SQL Server's Analysis Services has for online analytic processing (OLAP) and Data Transformation Services (DTS) has for extraction, transformation and load (ETL). Educational efforts by Microsoft will raise the profile of reporting technologies and the realization of their usefulness, while bringing usability and cost within the technical and budgetary grasp of far more companies.1

A valid SQL Server 2000 license is required for each server on which Reporting Services is deployed. It is available in nine languages including traditional and simplified Chinese, English, French, German, Italian, Japanese, Korean and Spanish.

About SQL Server

Microsoft SQL Server, part of the Windows Server System, is the complete database and analysis offering for rapidly delivering the next generation of scalable e-commerce, line-of-business and business intelligence solutions. It dramatically reduces the time required to bring these applications to market while offering the scalability needed for the most-demanding environments. More information on Microsoft SQL Server can be found at http://www.microsoft.com/sql/.


 
Categories: ADO.NET | News

October 17, 2003
@ 01:51 AM

SQLXML enables XML support for your SQL Server Database. It allows developers to bridge the gap between XML and relational data. You can create XML View of your existing relational data and work with it as if it was an XML file. SQLXML allows you to:

  • Build Web Services with SQL Server 2000
  • Build Web sites to publish data from SQL Server
  • Query relational database with XPath
  • Update relational data as if it was XML
  • Load XML into SQL Server
  • Query SQL Server via URLs, OLEDB/ADO or .NET Managed Classes

SP2 includes many fixes since the SP1 release including:

Identiy Propagation for XML Bulkload

Null Support for Web Services when used with Visual Studio .NET 2003

http://www.microsoft.com/downloads/details.aspx?FamilyID=4c8033a9-cf10-4e22-8004-477098a407ac&DisplayLang=en


 
Categories: ADO.NET | News | XML

One of the great new features with SQL Server 2000 is that it can directly output XML from a stored procedure. Then as a developer, you just need to deal with an xml document and all if the built-in features. The code below makes it easy to get xml from a stored procedure or an SQL statement using "FORM XML AUTO" at the end.

Dim pobjSQLConnection As New SqlClient.SqlConnection(ConfigurationSettings.AppSettings("dbconnect")) 
Dim pobjSQLCommand As SqlClient.SqlCommand
Dim pobjXMLReader As System.Xml.XmlReader
Dim pobjXML As New System.Xml.XmlDataDocument()
  Try
    pobjSQLConnection.Open()
    pobjSQLCommand = pobjSQLConnection.CreateCommand
    pstrSQL = "sp_GETCustomersNamesAsXML"
    pobjSQLCommand.CommandText = pstrSQL.ToString
    pobjXMLReader = pobjSQLCommand.ExecuteXmlReader()
    pobjXMLReader.Read()
    pobjXML.LoadXml(pobjXMLReader.ReadOuterXml)
    pobjSQLConnection.Close()
  Catch
    'Blow by errors if you want
  Finally
    pobjSQLCommand.Dispose()
    pobjSQLConnection.Dispose()
  End Try

Tip Submitted By: David McCarter


 
Categories: ADO.NET | XML

Below are some converted VB6 methods that do common database connection tasked. The first one (CheckSQLConnection) checks to make sure that a connection can be made to the database. This could be used at the beginning of your application or web application to make sure that the database is up. If it's not, doubt if there is much need in continuing.

The next method (CloseSQLConnection), closes a SQLConnection object if it is open. NEVER assume that the connection was successfully opened during the course of your application.

The last method (OpenSQLConnection), will open a SQLConnection object (and pass it back to the calling method) based on the connection string passed to it. The method will return True if it succeeded with no errors.

I always uses these methods wrapped with exception handling to open and close SQLConnections... safer that way. Also these methods use the new .NET SQLConnection object not the ADO object. The built in SQL objects in .NET have faster access to SQL than the ADO objects do! 

Imports System.Data
Imports System.Data.SqlClient
Public Function CheckSQLConnection(ByVal DBConnection As String) As Boolean
Dim pcnConnection As SQLConnection
  Try
    pcnConnection = New SQLConnection()
  Catch poExcep As Exception
    Return False
    Exit Function
  End Try
  Try
    pcnConnection.ConnectionString = DBConnection
    pcnConnection.Open()
  Catch poExcep As Exception
    'Could not make connection
    Return False
    Exit Function
  End Try
  If pcnConnection.State = ConnectionState.Open Then
    Return True
    Else
      Return False
  End If
  If Not pcnConnection Is Nothing Then
    CloseSQLConnection(pcnConnection)
  End If
End Function
Public Sub CloseSQLConnection(ByRef SQLConnObj As SQLConnection)
  Try
    If SQLConnObj.State <> ConnectionState.Closed Then
      SQLConnObj.Close()
    End If
  Catch poExcep As Exception
    'Blow by any errors
  End Try
End Sub
Public Function OpenSQLConnection(ByVal DBConnection As String, _
                                    ByRef SQLConnObj As SQLConnection, _
                                    Optional ByVal ConnectionTimeout As Integer = 15 _
                                    ) As Boolean
  If SQLConnObj Is Nothing Then
    Try
      SQLConnObj = New SQLConnection()
    Catch poExcep As Exception
      Return False
      Exit Function
    End Try
  End If
  'Setup Connection
  Try
    SQLConnObj.ConnectionTimeout = ConnectionTimeout
    SQLConnObj.ConnectionString = DBConnection
    SQLConnObj.Open()
  Catch poExcep As Exception
    Return False
    Exit Function
  End Try
  'Make sure it's open
  If SQLConnObj.State = ConnectionState.Open Then
    Return True
    Else
      Return False
  End If
End Function

Tip By: David McCarter


 
Categories: ADO.NET | VB.NET

http://www.microsoft.com/downloads/details.aspx?FamilyID=45f13070-f2f1-4b51-af91-b14425ff7745&DisplayLang=en


 
Categories: ADO.NET | dotNetDave | Link

The MDAC 2.7 SP1 Refresh release installs the same Data Access core components as Microsoft Windows XP SP1, with the addition of several important bug fixes. The MDAC 2.7 SP1 Refresh release is also included in the Microsoft SQL Server 2000 Service Pack 3a release.

This release does not include Microsoft Jet, the Microsoft Jet OLE DB Provider, the Desktop Database Drivers ODBC Driver, or the Visual FoxPro ODBC Driver.

Click here to download.


 
Categories: ADO.NET | News