Wednesday, March 26, 2008

Upgrading from SQL Express 2005 to SQL 2005 Developer Edition

Upgrading from SQL Express 2005 to SQL 2005 Developer Edition (2 hours)


Note: First ensure you have access to the following key in the registry


You are most likely an admin if you are installing Developer Edition of SQL 2005 so be sure the following setting is set.


Go to Start > Run > enter regedit>


SYSTEM\CurrentControlSet\Control\WMI\Security ß Give Admins Full Contrl (Be sure to change this back so you don’t get yourself into trouble)
>








Next slap the DVD or CD’s into your Rom Drive>


Start > Run > cmd>




Follow the prompts>










User your UID, PWD and Domain>


Your good to go when you see:>






Don't forget Service Pack 2

Tuesday, March 04, 2008

MCTS - SharePoint Developer

Passed the Microsoft Exam SharePoint 2007 Developer

I am now officially and Microsoft Certified Technical Specialist.

Wednesday, February 20, 2008

Back versus Attaching to MDF

Chintal my new programming parnter taught an old dog a new trick today. Instead of backing up and restoring databases simply open Windows Explorer and copy the .MDF and .LDF and zip move, copy, cut and attach back with SQL Server Management Studio SSMS.

Thursday, February 14, 2008

Working with Infrastructure in the Enterprise as a Programmer Analyst

For 10 years I have been working as an analyst first then putting on the programmer hat and developing applications. In corporate America you need to concentrate on your ability to work with your infrastructure architects and be very open minded. I have learned that you must take time to explain in great detail what your solution design is doing. Most web solutions involve web servers and database servers along with needing separate environments for development, user acceptance testing and production. Your solution may be Intranet or Internet, but the key to working with your infrastructure architect is to document, document, document. Use applications such as Visio to convey to them what you are trying to accomplish in the form of a picture (Remember a picture speaks a thousand words). It will save you your sanity and provide a great working relationship with your architect. Humans are not mind readers so document and draw your solution with time and patience. And last, but not least be sure to consult with your architect and have your environments built before coding a solution and ensure all the environment mirror one another, that way you will not freak out when your app works in one environment and not the other.

Words of Wisdom from an individual who loves what they do, but has pulled a bit of hair out learning the ropes.

Thanks to my mentors

Doug Cain
Larry Leonard
Eddie Clodfelter
Troy Tucker
Robert Petree
Shaun Todd
Saran
Garry Blanks
Kelly O'Donnell

Monday, February 04, 2008

Start explorer in C:

Start Windows Explorer In The C Drive
In the Explorer property sheet use this path and switches in the target:

C:\windows\explorer.exe /n,/e,c:\

Since the first days Windows Explorer appeared, the list of switches reproduced below has been floating around the internet. I'm not sure who was the first to assemble the list but here it is in its entirety. Play around with it and see if one of the views is what you're seeking. Just copy and paste the bold text into the Target line on the Property Sheet of Windows Explorer. If it's not what you expected you can always switch back to the default view by using C:\WINDOWS\explorer.exe in the Target line.

"My Computer" highlighted in left side with all drives visible but not expanded and C: highlighted in right side: %SystemRoot%\explorer.exe /e,/select,c:

Desktop highlighted and nothing expanded: %SystemRoot%\explorer.exe /e,/n,/select,/root,c:

All drives visible and the system drive highlighted and expanded in full screen: %SystemRoot%\explorer.exe /e,/select

All drives visible and the system drive expanded in small screen: %SystemRoot%\explorer.exe /e,/select,%systemroot%

Only Windows Directory visible highlighted and expanded: %SystemRoot%\explorer.exe /e,/root,%systemroot%

All drives visible but only C: highlighted and expanded: %SystemRoot%\explorer.exe /e,c:

Nothing expanded and My Computer highlighted in right side: %SystemRoot%\explorer.exe /n,/e,/select,

Opens the Windows folder as a folder: %SystemRoot%\explorer.exe %systemroot%

Opens as "My Computer": %SystemRoot%\explorer.exe %systemroot%,

This opens the Desktop folder with "My Computer" highlighted: %SystemRoot%\explorer.exe %systemroot%,/select,

"Desktop" highlighted in the left side and no drives visible:
%systemroot%\explorer.exe /e,/root,::{20D04FE0-3AEA-1069-A2D8-08002B30309D},/select

"My Computer" highlighted in left side and all drives visible but none expanded:
%systemroot%\explorer.exe /e,/root,::{20D04FE0-3AEA-1069-A2D8-08002B30309D}

"Desktop" in left side highlighted and "My Computer" highlighted in right side and no drives visible:
%systemroot%\explorer.exe /e,/select,::{20D04FE0-3AEA-1069-A2D8-08002B30309D}

Wednesday, January 02, 2008

Kill Instance of Application

Recently I was receiving an issue with an application I am supporting.
 
Problem
The application is a .NET Console application that using Microsoft Word to create reports. The problem is that an exception error would occur if Microsoft Word (WINWORD = Instance Name) was running.
 
Solution

// Code to kill Word issues if WINWORD is running on the current machine

// if word is running the reports will throw an exception so

// we must ensure the Microsoft Word application is not running

Process[] wordProcess = System.Diagnostics.Process.GetProcessesByName("WINWORD");
if
(wordProcess.Length <= 1)
{

 foreach (Process p in wordProcess)

{

p.Kill();

}

}

Thursday, December 20, 2007

Year End

Well, another year is coming to an end and what a year it has been. I have seen my Wife and daughter grow to be best little buddies. Also my daughter learning at an incredible pace. As for my life in the development world I took on a new job. Switched from R.J. Reynolds to Bank of America in July.This was a great move with more challenging work. This year I can add to my resume that I am a Microsoft SharePoint 2007 Guru, Microsoft InfoPath Developer, .NET Web Service Developer, along with SQL Server Reporting Services. Visual Studio 2008, so that will be my new challenge next year.

Tuesday, December 18, 2007

dbcc checkident('table_name', reseed, 0)
 
Reset Database identity

Friday, December 14, 2007

Answer Re: A transport-level error has occurred when sending the request to the server
Answer Was this post helpful ?
Reply Quote

For some reason the connection was made through Named Pipes instead of Shared Memory (the default for local connections), which suggests that SqlClient did not recognize the connection was local, and most likely tunneled Named Pipes over TCP, hence, disconnecting the network has impact. 

How do you specify the server name - perhaps by its fully qualified domain name (FQDN), or IP address? 

If you specify it by the hostname or "." or "(localhost)" SqlClient should recognize the local connection, and you should not see the error. 

Stored Procs

Please be aware if you are inserting data into a data field with a value type of int and allows null be sure to set the @Param int = null

This will prevent errors when submitting.

Wednesday, December 12, 2007

InfoPath class file from export

xsd.exe myschema.xsd /classes /l:cs /n:[NAMESPACE]

Identity Information

Introduction

 

About Identity Columns

If you have worked with SQL Server, you are probably familiar with identity columns. These are equivalent to the "AutoNumber" columns in Access. The main purpose of these columns is to provide a primary key to the table when a primary key cannot be defined using other fields in the table.

 

These columns are like any other column except that their value is not inserted by the user, but by the system itself.

Syntax

IDENTITY [ ( seed , increment ) ]

Where:

seed - Is the value that is used for the very first row that is inserted into the table.

increment- Is the incremental value that is added to the previous identity value and thereby to get new value for the new row that is going to be added.

Note: You must specify both the seed and increment or neither. If neither is specified, the default is (1,1).

 

A few things you need to know about the identity columns:

·         They should be of data type int, smallint, tinyint, decimal or numeric with scale 0.

·         They cannot contain null values

·         They cannot have any default values

·         The identity increment is an integral value (1, -1, 5, etc.) and cannot contain decimals. Also, it cannot be 0.

·         Identity Seed is 1 by default, and so is the Identity Increment. If you leave the seed field empty, it becomes 0.

 

 

Functions associated with IDENTITY column

·               @@IDENTITY
When a record is inserted into a table with an identity column, the function @@IDENTITY returns the last identity value that was inserted in the database.

Syntax

@@IDENTITY

 

I emphasize the phrase "last identity value" here because this may be different from the identity value of that particular table where the record was inserted.

Why? When a record is inserted and if there is any underlying trigger that modifies other tables, the value can be different. If a trigger adds a record into another table, which happens to have an identity column, @@IDENTITY will now return this new value instead.

 

·               Scope_IDENTITY

Returns the last IDENTITY value inserted into an IDENTITY column in the same scope. A scope is a stored procedure, function, or batch. Thus, two statements are in the same scope if they are in the same stored procedure, function, or batch. It may be more clear from the example below.

Syntax

SCOPE_IDENTITY()

 

·               IDENT_CURRENT

Returns the last identity value generated for a specified table in any session and any scope.

Syntax

IDENT_CURRENT('table_name')

 

·               IDENT_SEED

Returns the seed value specified during the creation of an identity column in a table that has an identity column.

Syntax

IDENT_SEED('table_name')

 

·               IDENT_INCR

Returns the increment value specified during the creation of an identity column in a table that has an identity column.

Syntax

IDENT_INCR('table_name')


Examples and Tips

 

Example

-- Consider the 2 Tables

CREATE TABLE Student(studId int IDENTITY(1,1), studName varchar(30))

CREATE TABLE Copy_Student(sid int IDENTITY(100,1))

GO

 

--Create trigger for insert on table Student

CREATE TRIGGER trgStudent ON Student FOR INSERT

AS

BEGIN

   INSERT INTO Copy_Student DEFAULT VALUES

END

GO

 

--Check The Tables

SELECT  *  FROM Student    --No records

SELECT  *  FROM Copy_Student --No records

GO

--Now do the following to check out the difference

 

 

INSERT INTO Student(studName) VALUES('Anjali Chelawat')

 

SELECT @@IDENTITY AS [IDENTITY]

 

--Returns the value 100, which was inserted by the trigger that is by the second insert statement.

 

 

SELECT SCOPE_IDENTITY() AS [SCOPE_IDENTITY] 

 

--Returns the value 1, which was inserted by the Student table INSERT Statement before the trigger's insert statement.

 

 

SELECT IDENT_CURRENT('student') AS [IDENT_CURRENT]

 

--Returns last identity value inserted into Student.

 

 

 

SELECT IDENT_CURRENT('copy_student') AS [IDENT_CURRENT]

 

--Returns last identity value inserted into Copy_Student.

 

 

SELECT IDENT_INCR('student') AS [IDENT_INCR]

 

-- Returns the increment value of the identity column of the table Student. The value provided at the time of creation of the identity column

 

 

SELECT IDENT_SEED('student') AS [IDENT_SEED]

 

-- Returns the seed value of the identity column of the table Student. The value provided at the time of creation of the identity column

 

 

 

A Few Tips

·         Allowing inserts to identity columns:

 

If you are inserting data from some other source to a table with an identity column and you need to ensure you retain the identity values, you can temporarily allow inserts to the identity column. Without doing so explicitly you will receive an error if you attempt to insert a value into the identity column. For example, if I have a table named MYTABLE and I want to allow inserts into the identity column, I can execute the following:

Syntax

set identity_ insert  table_name on

 

Once you execute the command you will be able to insert values into the table's identity column. This will stay in effect in until you turn it off by executing the following:

 

Syntax

 

set identity_insert table_name off

 

Note: Be aware that at any time, only a single table in a session can have the identity_insert set to on.  If you attempt to enable this for a table and another table already has this enabled, you will receive an error and will not be able to do so until you first turn this off for the other table. Also, if the value used for the identity is larger than the current identity value then the new value will be used for the identity seed for the column.  

 

 

·         Reseeding the identity value:

 

You can reseed the identity value, that is, to have the identity values reset or start at a new predefined value by using DBCC CHECKIDENT.  For example, if I have a table named MYTABLE and I want to reseed the identity column to 30 I would execute the following:

 

dbcc checkident (‘table_name’, reseed, 30)

 

If you wanted to reseed the table to start with an identity of 1 with the next insert then you would reseed the table's identity to 0.  The identity seed is what the value is currently at, meaning that the next value will increment the seed and use that.  However, one thing to keep in mind is that if you set the identity seed below values that you currently have in the table, that you will violate the identity column's uniqueness constraint as soon as the values start to overlap.  The identity value will not just “skip” values that already exist in the table.

 

 

 

Points To Remember

·   IDENT_CURRENT returns the last identity value generated for a specific table in any session and any scope.

·   @@IDENTITY returns the last identity value generated for any table in the current session, across all scopes.

·   SCOPE_IDENTITY returns the last identity value generated for any table in the current session and the current scope.

 

Credit to:

All About IDENTITY Columns in Sql Server 2000
by Anjali Chelawat
Published on 10/5/2006

Thursday, November 29, 2007

SQL Reporting Notes

SQL Reporting Notes
 
I noticed an issue with SQL Reporting and the PDF formatting.  I was receiving a lot of extra pages between page breaks.  I realized that the grid margins had moved to be extremely wide which caused the problem.
 
If you have this problem be sure to check your margins.


If you are developing a 11" x 8.5" be sure that your grid is equal to your width minus the margin for left and right.

Example you have a report to be 11" wide with 1/2" margins this means your grid and I repeat cannot be wider than 10" or you will have blank pages and please be sure not to nudge it by accident.

Tuesday, November 27, 2007

SQL Reporting Services Expression

If you ever need to insert "data not available" or "n/a" use the following code.

=IIf(Fields!HoursAllocated.Value is nothing, "No Data Supplied", Fields!HoursAllocated.Value)

ASP.NET Account locked out please check before banging your head.

aspnet_wp.exe could not be started. The error code for the failure is 80004005. This error can be caused when the worker process account has insufficient rights to read the .NET Framework files. Please ensure that the .NET Framework is correctly installed and that the ACLs on the installation directory allow access to the configured account.

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

aspnet_wp.exe could not be launched because the username and/or password supplied in the processModel section of the config file are invalid.

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

 

Check the following:  Make sure the ASP.NET Machine Account is not locked out...  It will save you a lot of headaches.

Monday, November 26, 2007

%HOME%%HOMEPATH%

Have you ever needed to use RUNAS for testing security on your applications?
 
If so, and you have gotten a second account for testing and get weird errors such as not finding the application be sure to change the Start In to point to the actual executables location rather than the %HOME%%HOMEPATH%

Tuesday, November 13, 2007

Check empty array Trick

The old trick for checking for an empty array is

Dim X() As String

If (Not X) = -1 Then
Debug.Print "empty"
Else
Debug.Print "UBound is " & UBound(X)
End If

Wednesday, November 07, 2007

InfoPath and Web Services

Have you ever had this issue developing a Web service with InfoPath?

InfoPath cannot submit the form.
An error occurred while the form was being submitted.
The SOAP response indicates that an error occurred:

System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP
Header SOAPAction:http://localhost <-- Questions Have you changed the URL here but it the change does not work on the Submit for the InfoPath form?

Well first things first. Every time you update the Web service you need to re-do the connection to the Web service inside of InfoPath. I discovered this after about 2 hours of trying to find out what I was doing wrong in my code VS.NET 2005 UGH!!!!

Hack away fellow gurus.





More to come on the solution I am working on. I am thinking about creating a White Paper and I will include all Blogs that have helped me with this solution.

Wednesday, October 10, 2007

Data Types

Data types defined for SQL Server http://msdn2.microsoft.com/en-us/library/aa258271(SQL.80).aspx

Difference between varable and fixed -

When you design your tables, it helps to understand the tradeoffs of using variable length columns versus fixed length columns. Variable length columns reduce database size because they take only what is required to store the actual value. Fixed length columns always take maximum space defined by the schema, even when the actual value is empty. The downside for variable length columns is that some operations are not as efficient as those on fixed length columns. For example, if a variable length column starts small and an UPDATE causes it to grow significantly, the record might have to be relocated. Additionally, frequent updates cause data pages to become more fragmented over time. Therefore, we recommend that you use fixed length columns when data lengths do not vary too much and when frequent updates are performed (Microsoft - http://technet.microsoft.com/en-us/library/ms172432.aspx.

Unicode vs. Non-Unicode - The primary difference between unicode and non-unicode data types is the ability of unicode to easily handle the storage of foreign language characters which also requires more storage space.