Monday, January 12, 2009

Enable Remote Connections in SQL Express

Read the following article http://support.microsoft.com/default.aspx?scid=kb;EN-US;914277

 

To enable remote connections on the instance of SQL Server 2005 and to turn on the SQL Server Browser service, use the SQL Server 2005 Surface Area Configuration tool. The Surface Area Configuration tool is installed when you install SQL Server 2005.

http://support.microsoft.com/library/images/support/kbgraphics/public/en-us/uparrow.gifBack to the top

Enable remote connections for SQL Server 2005 Express or SQL Server 2005 Developer Edition

You must enable remote connections for each instance of SQL Server 2005 that you want to connect to from a remote computer. To do this, follow these steps:

1.     Click Start, point to Programs, point to Microsoft SQL Server 2005, point to Configuration Tools, and then click SQL Server Surface Area Configuration.

2.     On the SQL Server 2005 Surface Area Configuration page, click Surface Area Configuration for Services and Connections.

3.     On the Surface Area Configuration for Services and Connections page, expand Database Engine, click Remote Connections, click Local and remote connections, click the appropriate protocol to enable for your environment, and then click Apply.

Note Click OK when you receive the following message:

Changes to Connection Settings will not take effect until you restart the Database Engine service.

4.     On the Surface Area Configuration for Services and Connections page, expand Database Engine, click Service, click Stop, wait until the MSSQLSERVER service stops, and then click Start to restart the MSSQLSERVER service.

http://support.microsoft.com/library/images/support/kbgraphics/public/en-us/uparrow.gifBack to the top

Enable the SQL Server Browser service

If you are running SQL Server 2005 by using an instance name and you are not using a specific TCP/IP port number in your connection string, you must enable the SQL Server Browser service to allow for remote connections. For example, SQL Server 2005 Express is installed with a default instance name of Computer Name\SQLEXPRESS. You are only required to enable the SQL Server Browser service one time, regardless of how many instances of SQL Server 2005 you are running. To enable the SQL Server Browser service, follow these steps.

Important These steps may increase your security risk. These steps may also make your computer or your network more vulnerable to attack by malicious users or by malicious software such as viruses. We recommend the process that this article describes to enable programs to operate as they are designed to, or to implement specific program capabilities. Before you make these changes, we recommend that you evaluate the risks that are associated with implementing this process in your particular environment. If you choose to implement this process, take any appropriate additional steps to help protect your system. We recommend that you use this process only if you really require this process.

1.     Click Start, point to Programs, point to Microsoft SQL Server 2005, point to Configuration Tools, and then click SQL Server Surface Area Configuration.

2.     On the SQL Server 2005 Surface Area Configuration page, click Surface Area Configuration for Services and Connections.

3.     On the Surface Area Configuration for Services and Connections page, click SQL Server Browser, click Automatic for Startup type, and then click Apply.

Note When you click the Automatic option, the SQL Server Browser service starts automatically every time that you start Microsoft Windows.

4.     Click Start, and then click OK.

Note When you run the SQL Server Browser service on a computer, the computer displays the instance names and the connection information for each instance of SQL Server that is running on the computer. This risk can be reduced by not enabling the SQL Server Browser service and by connecting to the instance of SQL Server directly through an assigned TCP port. Connecting directly to an instance of SQL Server through a TCP port is beyond the scope of this article. For more information about the SQL Server Browser server and connecting to an instance of SQL Server, see the following topics in SQL Server Books Online:

  • SQL Server Browser Service
  • Connecting to the SQL Server Database Engine
  • Client Network Configuration

http://support.microsoft.com/library/images/support/kbgraphics/public/en-us/uparrow.gifBack to the top

Create exceptions in Windows Firewall

These steps apply to the version of Windows Firewall that is included in Windows XP Service Pack 2 (SP2) and in Windows Server 2003. If you are using a different firewall system, see your firewall documentation for more information.

If you are running a firewall on the computer that is running SQL Server 2005, external connections to SQL Server 2005 will be blocked unless SQL Server 2005 and the SQL Server Browser service can communicate through the firewall. You must create an exception for each instance of SQL Server 2005 that you want to accept remote connections and an exception for the SQL Server Browser service.

SQL Server 2005 uses an instance ID as part of the path when you install its program files. To create an exception for each instance of SQL Server, you must identify the correct instance ID. To obtain an instance ID, follow these steps:

1.     Click Start, point to Programs, point to Microsoft SQL Server 2005, point to Configuration Tools, and then click SQL Server Configuration Manager.

2.     In SQL Server Configuration Manager, click the SQL Server Browser service in the right pane, right-click the instance name in the main window, and then click Properties.

3.     On the SQL Server Browser Properties page, click the Advanced tab, locate the instance ID in the property list, and then click OK.

To open Windows Firewall, click Start, click Run, type firewall.cpl, and then click OK.

Create an exception for SQL Server 2005 in Windows Firewall

To create an exception for SQL Server 2005 in Windows Firewall, follow these steps:

1.     In Windows Firewall, click the Exceptions tab, and then click Add Program.

2.     In the Add a Program window, click Browse.

3.     Click the C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Binn\sqlservr.exe executable program, click Open, and then click OK.

Note The path may be different depending on where SQL Server 2005 is installed. MSSQL.1 is a placeholder for the instance ID that you obtained in step 3 of the previous procedure.

4.     Repeat steps 1 through 3 for each instance of SQL Server 2005 that needs an exception.

Create an exception for the SQL Server Browser service in Windows Firewall

To create an exception for the SQL Server Browser service in Windows Firewall, follow these steps:

1.     In Windows Firewall, click the Exceptions tab, and then click Add Program.

2.     In the Add a Program window, click Browse.

3.     Click the C:\Program Files\Microsoft SQL Server\90\Shared\sqlbrowser.exe executable program, click Open, and then click OK.

Note The path may be different depending on where SQL Server 2005 is installed.

http://support.microsoft.com/library/images/support/kbgraphics/public/en-us/uparrow.gifBack to the top


APPLIES TO

  • Microsoft SQL Server 2005 Developer Edition
  • Microsoft SQL Server 2005 Express Edition

 

 

 

Friday, January 02, 2009

Happy New Year

Happy New Year to all and I am looking forward to a happy, prosperous, healthy and knowledge filled year.  I wish everyone goodness and joy.  Remember to focus on your family and loved ones.

 

This year I will be looking to achieve a weekly blog post to reflect on the week.

 

Moojjoo

Sunday, December 21, 2008

12/21/2008 - Code thoughts

I have been wondering what a laptop is like with just ubuntu.  I am a .NET guy and I would have to convert to Apache, PHP, mySQL.  Which are all free.

 

__________________________________________

Robert B. Dannelly, Jr. MCTS

http://www.mmwebs.com/

http://moojjoo.blogspot.com/

 

Friday, December 19, 2008

Configure Firefox to work with localhost.

Here is the Solution for Other Users
Firefox - Enter username and password for "" at http://localhost - Solution
IIS uses Integrated Authentication and by default IE has the ability to use your windows user account...but don't worry, so does Firefox but you'll have to make a quick configuration change.

1) Open up Firefox and type in about:config as the url

2) In the Filter Type in ntlm

3) Double click "network.automatic-ntlm-auth.trusted-uris" and type in localhost and hit enter

4) Write Thank You To Blogger


As Always, Hope this helped you out.

Wednesday, December 10, 2008

Christmas is coming

Christmas is coming, SANTA, SANTA....

December post

Well, I must say life has been busy for November I got handed over 43 servers for a true dev to prod environment of SharePoint.

Wednesday, October 15, 2008

Outlook notes on desktop

Credit to http://www.onetipaday.com/2006/10/15/how-to-save-put-outlook-notes-on-your-desktop

I often use the Microsoft Outlook Notes to store To-Do lists that are not related to work. I discovered this great tip a few months which allows me to put my notes on my desktop, and I love it as it means I can access my notes without having to open up Outlook.

To create a note in Outlook:

1. On the File menu, point to New, and then click Note.
2. Type the text of the note.
3. To close the note, click the × in the upper-right corner of the note.

Then to put the notes on your desktop do the following:

1. Right-click the desktop, point to New, and click Shortcut.
2. In the Type the location of the item box, type the following path: “C:\Program Files\Microsoft Office\OfficeXX\OUTLOOK.EXE” /c ipm.stickynote (note OfficeXX - XX needs to be replaced with your version of Office.
3. Click Next, name the shortcut, and then click Finish.

Now, when you double-click the shortcut, an Outlook note will appear on your desktop.

Excel Services Event ID: 5226

If you have installed SharePoint per default configurations you will most likely not get issues like this, but in most enterprise installs logs and temp files are relocated. To fix the error below. Please review error then read below for solution.

Event Type: Error
Event Source: Office SharePoint Server
Event Category: Excel Calculation Services
Event ID: 5226
Date: 10/15/2008
Time: 9:32:36 AM
User: N/A
Computer: CR2RCHIISIME
Description:
Unable to create or access workbook cache at D:\Temp\Excel Server\FileCache\BaselII-CIT-SSP-423345403\Charts. Excel Services is unable to function without a workbook cache.

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


Solution I manually created the D:\Temp\Excel Server\FileCache\BaselII-CIT-SSP-423345403\Charts directory then on the Security tab for the Temp directory, the WSS_ADMIN_WPG Windows group should have Full Control and the WSS_WPG Windows group should have Read & Execute, List Folder Contents, and Read permissions or higher on the folder. If they do not, assign these permissions by using the procedure in the "Assign sufficient permissions" section.

Also, this solution works if you get Trace Log errors.

Friday, August 01, 2008

Date in Task Bar

Got this from Windows XP site. Worth re-post

To display the date as well as the time, you need to make the taskbar "taller" by dragging the top edge upward. This procedure is fairly simple but it does require reasonably precise mouse handling. If you are new to computing and still developing your mouse-skills, expanding the taskbar, or returning it to the default height, may prove to be a little problematical. If you are not yet confident with fiddly mouse manipulation, I would suggest that you postpone using this tip until you gain more mousing experience.

Here's how to expand the taskbar:

The taskbar needs to be "unlocked" before you can expand it. To check, right-click the taskbar and ensure that "Lock the Taskbar" is not ticked. If there is a tick, click "Lock the Taskbar" to untick it.

Close any running programs so that the taskbar is uncluttered and easier to manipulate.

Move your mouse to the top edge of the taskbar until the cursor turns into a doubled-ended arrow.

With the doubled-ended arrow displayed, hold down the left mouse button and drag the taskbar upward until it is about twice the normal height.

The day and date should now be displayed below the Notification Area clock.

If desired, you can now re-lock the taskbar.
The expanded taskbar not only permanently displays the day and date, it also provides extra display space for taskbar and notification area icons. Of course, the downside of an expanded taskbar is that you have less screen display area for programs and files.

To return the taskbar to its original height, follow the procedure outlined above but reverse the drag direction specified in step 4. That is, with the doubled-ended arrow displayed, hold down the left mouse button and drag the taskbar towards the bottom of the screen until it is the normal height.

Tuesday, July 29, 2008

SQL Server Reporting Services Datasource Security

http://technet.microsoft.com/en-us/library/ms160330.aspx

Stored Credentials
You can store the credentials used to access an external data source. Credentials are stored in reversible encryption in the report server database. You can specify one set of stored credentials for each data source used in a report. The credentials you provide retrieve the same data for every user who runs the report.

Stored credentials are recommended as part of a strategy for accessing remote database servers. Stored credentials are required if you want to support subscriptions, or schedule report history generation or report snapshot refreshes. When a report runs as as a background process, the report server is the agent that executes the report. Because there is no user context in place, the report server must get credential information from the report server database in order to connect to a data source.

The user name and password that you specify can be Windows credentials or a database login. If you specify Windows credentials, the report server passes the credentials to Windows for subsequent authentication. Otherwise, the credentials are passed to the database server for authentication.

Windows Integrated Security
When you use the Windows Integrated Security option, the report server passes the security token of the user accessing the report to the server hosting the external data source. In this case, the user is not prompted to type a user name or password.

This approach is recommended if Kerberos is enabled. If Kerberos is not enabled, you should only use this approach if all the servers that you want to access are located on the same computer.

In other words each user would need to be added access to the Database Hosted on SQL Server

Wednesday, July 02, 2008

SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified or Named Pipes Provider, error: 40 - Could not open a connection to SQL S

The problem was that the remote connection needed to utilize Named Pipes, but in order to utilize Named Pipes both the machine hosting the instance of SQL and the my local machine must have the alias:

With Supports instruction I went to SQL Server configuration Manager, expanded SQL Native Client Configuration and right clicked Aliases and created the alias on the machine and did the same for my personal machine and what do you know, it worked.

Tuesday, July 01, 2008

How to determine what ports are open

start -> run -> cmd
netstat -na

look for :3306 and LISTEN on the same line...

OR..also from command prompt

telnet localhost 3306

Friday, June 27, 2008

Vitual PC 2007

Well, it has been a while since I have blogged due to the project I am working on at work. The project MOSS 2007 from dev, test, and prod.

Before dev there is a place called pre-dev, where developers like myself need a place to develop, so this past March I attended the SharePoint 2007 conference where I met some great resources and obtained a VHD of MOSS 2007 and learned that most developer's develop in this fashion by downloading and installing the software from the MSDN Subscription, and routing code to a source control server.

Well I installed and could not get it to run, due to my lack of knowledge of Virtual PC 2007. I have a laptop with 1 gig of RAM and a external HD with 500 gig so I installed the VHD and fired up the Virtual PC, but I kept getting an error. Not enough memory on the host machine.

I thought to myself, "That is strange 1 gig should be enough memory to get my image up and running." Well it turns out I had to much memory allocated to the VM, so I set it back to 512mb and bam... The VM started to run, but it is also running dog slow, so in closing have 2 gig of RAM so you can allocate 1 gig to the VM.

Hope this helps out my fellow developers.

OUT... Moojjoo

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.

Tuesday, September 11, 2007

Backup and Restore on SQL Server

thanks to moonguy on MSDN he saved me many hours of work.

When you try to backup, SQL Server 2005 shows the default backup path i.e. c:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\ . This directory default has SQL user rights. Go to Backup directory and check the user name. Its very big name and I have not checked how SQL server adds it in allowed users list. You can do 2 things:



1. Let the Server take backup on default directory and copy the file in your desired folder. I did that.

2. Give same kind of permissions to your desired folder as Backup directory has.



Hope it solves the issue.



Moonguy

Tuesday, August 14, 2007

Settings.Settings .NET C#

I just learned the newest feature for adding configuration to .NET application (Console, Windows Forms, Web forms, ets.)

Settings.Settings are created when you start your application. This allows you to build out Settings that scope either the application or user. But the big question was how do you access them in the code.

Simple.

Try this

Properties.Settins.Default.[Intellisense takes over and find your setting]

That easy.

Friday, July 13, 2007

InfoPath Designer Mode

Well, after all the research I found Tim Pash as you can see in the post below. It seems that in the Corporate Enviroment you have to request that you have the setting deployed to you by your Microsoft Office Deployment and Configuration team. So with that being said, if you do not see the designer feature in InfoPath send a request to you Information Technology Team.

Wednesday, July 11, 2007

InfoPath

Well,

I am now back contracting because of my love to CODE. I have a new venture at Bank of America using SharePoint, InfoPath, and Visual Basic for Applications (VBA). My first task is to figure out how to enable InfoPath to allow me to design?

I found a great resource from the Tim Pash: http://blogs.msdn.com/timpash/archive/2006/02/08/Prevent-Design-Mode-For-Users.aspx?CommentPosted=true#commentmessage

Thursday, June 21, 2007

Update from comparison of two SQL tables

UPDATE o
SET Amount=Price
FROM orders o JOIN items i ON (o.ItemNumber=i.ItemNumber)

UPDATE o SET EmpActive = 0 FROM ComplianceEmployee o
JOIN ComplianceEmployeeLoad i ON (o.EmpID = i.EmpID)

Sunday, May 20, 2007

GoDaddy.com System.Net.Mail Solution

Here is the C# version of the GoDaddy.com ASP.NET 2.0 Send Mail by Moojjoo http://www.mmwebs.com

Web.Config
<?xml version="1.0"?>

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<system.web>

<customErrors mode="Off"/>
<compilation debug="true"/> <!-- Be sure to change this to false when going to production -->

</system.web>
<system.net>

<mailSettings>
<smtp>

<network

host="relay-hosting.secureserver.net" />
</smtp>

</mailSettings>
</system.net>

</configuration>



.cs code behind for your .aspx page

protected void btnSubmit_Click(object sender, EventArgs e)
{

MailMessage myMail = new MailMessage();

myMail.From = new MailAddress("from@yourdomain.com");
myMail.Subject = "Contact Form";

MailAddressCollection myMailTo = new MailAddressCollection();
myMail.To.Add("to@domain.com");

StringBuilder sb = new StringBuilder();
sb.Append("Last Name: " + txtFirstName.Text + "<br>");

sb.Append("First Name: " + txtFirstName.Text + "<br>");
sb.Append("Address: " + txtAddress.Text + "<br>");

sb.Append("City: " + txtCity.Text + "<br>");
sb.Append("State: " + ddlState.SelectedValue + "<br>");

sb.Append("Zip: " + txtZip.Text + "<br>");
sb.Append("Email: " + txtEmail.Text + "<br>");

sb.Append("Questions/Comments: " + txtQandC.Text + "<br>");string strBody = sb.ToString();
myMail.Body = strBody;

myMail.IsBodyHtml = true;

SmtpClient smtp = new SmtpClient();
smtp.Credentials = CredentialCache.DefaultNetworkCredentials;

try

{

smtp.Send(myMail);

myMail = null;
}

catch (System.Exception ex)
{

Response.Write(ex.Message);

}

}

Moojjoo Õ¿Õ

http://www.mmwebs.com

http://www.autoinventoryonline.com/

Sunday, January 28, 2007

ASP.NET 2.0 - Membership and Roles

Today, I have been working with SQL Server 2000 and Visual Studio 2005 to increase my speed in development by using Strongly Typed Datatypes and the Membership/Roles provided by SQL.

For now I am going to jump into using the Membership/Roles provided by ASP.NET.

Microsoft has made it easy to setup membership/role for you Web application, but did not explain the needs most freelance developers must use in order to use rented Web hosting space.

As for my self I develop on http://www.idevconsultants.com/ servers and they run SQL 2000. And not to mention I do not have keys to the server so I have to develop with what I can without making changes to IIS. This is the same for most developers.

So here is the trick to use this new membership tools.

Scott Gu blog http://weblogs.asp.net/scottgu/archive/2005/08/25/423703.aspx explains the ends and outs, but basically the secret is to run the following tool:

Open a command-line window on your system and run the aspnet_regsql.exe utility that is installed with ASP.NET 2.0 in under your C:\WINDOWS\Microsoft.NET\Framework\v2.0.xyz directory. This tool will build all the Tables, StoredProcs needed to run the membership tools in ASP.NET 2.0.

VERY IMPORTANT: Next in your WEB.CONFIG name your connection string to

















Again DO NOT I REPEAT DO NOT change the name...

Wednesday, January 10, 2007

Testing Visual Studio with Firefox

In my job I develop for Intranets (IE) and Internet (All Browsers) and order to test Firefox I found the following article which was crucial to setting up the Firefox browser for testing an ASP.NET 2.0 application in order to get NTLM to work.

http://brennan.offwhite.net/blog/2005/07/22/firefox-authentication-with-ntlm/

Be sure to add localhost to your proxy if needed.

Saturday, November 11, 2006

SQL

This week I was told about a book titled, "Gurus Guide to Transact SQL". So being told about the book I headed to the local Borders with my daughter to check the book out. This book first and for most is better purchased online it is a lot cheaper.

This book is the ultimate guide to SQL Server Transact-SQL. T-SQL is a must for any developer utlizing SQL Server as their backend DBMS (Data Base Management System).

Sunday, October 15, 2006

Back on the blog

Moojjoo here and I am would like to apologize for not writting more. Having a 7 month old is a lot of work and not to mention the full plate I have at work lately.

I am very excited that my current company R.J. Reynolds Tobacco Company is finally moving forward to ASP.NET 2.0 and Visual Studio 2005.

As for coding I have really been researching the ability to use tiers in development so I can use as much resuse as possible.

Til Later

Friday, June 16, 2006

Using .NET Outlook to send formatted email

Imports Microsoft.Office
Imports Microsoft.Office.Core
Imports System.Runtime.InteropServices
Imports Outlook = Microsoft.Office.Interop.Outlook


Public Class TestOutlookMail
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
Private Sub InitializeComponent()

End Sub
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Private app As Outlook.ApplicationClass

'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
app = New Outlook.ApplicationClass
End Sub

'Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' CreateEmailMessage()
'End Sub 'button1_Click


'Private Sub CreateEmailMessage()
' 'Initialize the envelope values.
' Dim strTo As String = "yourname@yourdomain.com"
' Dim strBCC As String = "yourname@yourdomain.com"
' Dim strCC As String = "yourname@yourdomain.com"
' Dim strSubject As String = "Outlook Automation"
' Dim strBody As String = "Hello World"

' 'Automate the Outlook mail item.
' app = New Outlook.ApplicationClass
' Dim mItem As Outlook.MailItemClass = CType(app.CreateItem(Outlook.OlItemType.olMailItem), Outlook.MailItemClass)
' 'Dim As Outlook.MailItemClass = CType(doc.MailEnvelope.Item, Outlook.MailItemClass)
' 'Outlook.MailItemClass mi = (Outlook.MailItemClass)app.CreateItem
' mItem.To = strTo
' mItem.BCC = strBCC
' mItem.CC = strCC
' mItem.Subject = strSubject
' mItem.BodyFormat = Outlook.OlBodyFormat.olFormatHTML
' mItem.HTMLBody = strBody
' 'mItem.ItemEvents_Event_Close += New Outlook.ItemEvents_CloseEventHandler(Me.wApp_Close)

' 'wApp.Visible = True

' ' Loop until there are no more references to release.
' While Marshal.ReleaseComObject(mItem) > 0
' End While
' mItem = Nothing

' ' Invoke the .NET garbage collector.
' GC.Collect()
' GC.WaitForPendingFinalizers()
'End Sub 'CreateEmailMessage

Private Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Subject As String = "This is my Subject"
Dim Body As String = "This is my Body"


Dim mi As Outlook.MailItemClass = CType(app.CreateItem(Outlook.OlItemType.olMailItem), Outlook.MailItemClass)
mi.BodyFormat = Outlook.OlBodyFormat.olFormatHTML
mi.HTMLBody = Body
mi.Subject = Subject
mi.Display(New Object)

Dim ni As Outlook.NoteItemClass = CType(app.CreateItem(Outlook.OlItemType.olNoteItem), Outlook.NoteItemClass)
ni.Body = "This is my Body again"
ni.Display(New Object)

Dim pi As Outlook.PostItemClass = CType(app.CreateItem(Outlook.OlItemType.olPostItem), Outlook.PostItemClass)
pi.Subject = Subject
pi.BodyFormat = Outlook.OlBodyFormat.olFormatHTML
pi.Body = Body

pi.Display(New [Object])
End Sub 'button1_Click


End Class

Thursday, June 15, 2006

DropDown in DataGrid, How to Select

This is a two parter. First we will discuss on to add a "Select Value" to the Drop Down List after we populate the DropDown with Data from the Database then I will discuss how to Select that value using the OnItemDataBound from the DataGrid.

Inside the DataGrid you must use a Template like so

Thursday, June 08, 2006

SQL Time Converter

Private Sub BuildSQLTime(ByVal strProdDate, ByVal strProdTime)
Dim SQLDateTime As DateTime
Dim strDate As String = strProdDate
Dim strTime As String = strProdTime

Dim DateArray(2) As String
DateArray(0) = strDate.Substring(0, 2)
DateArray(1) = strDate.Substring(2, 2)
DateArray(2) = strDate.Substring(4, 2)

Dim tempDateTime As String
Dim newDateTime As DateTime

tempDateTime = DateArray(1) & "/" & DateArray(2) & "/" & DateArray(0)
newDateTime = Convert.ToDateTime(tempDateTime & " " & strTime)
'newDateTime = DateTime.Now

lblResults.Text = newDateTime
End Sub

Tuesday, May 30, 2006

Update to Access Folders without reboot

Need to access a folder you were just given access to? No need to reboot. Simply go to Start > Run > Type CMD At the dos prompt type gpupdate

Friday, May 19, 2006

SQL Server Leading Zeros for CHAR Type

declare @DirectiveNumber char(6)
declare @DirLength int



SET @DirectiveNumber = (SELECT DirectiveNumber FROM dbo.tblPlants WHERE PlantId = '1201')

--UPDATE dbo.tblPlants SET DirectiveNumber =
SET @DirectiveNumber = @DirectiveNumber + 1

Select @DirLength = LEN(@DirectiveNumber)

IF (@DirLength = 1)
SET @DirectiveNumber = '00000' + @DirectiveNumber
IF (@DirLength = 2)
SET @DirectiveNumber = '0000' + @DirectiveNumber
IF (@DirLength = 3)
SET @DirectiveNumber = '000' + @DirectiveNumber
IF (@DirLength = 4)
SET @DirectiveNumber = '00' + @DirectiveNumber
IF (@DirLength = 5)
SET @DirectiveNumber = '0' + @DirectiveNumber

UPDATE dbo.tblPlants SET DirectiveNumber = @DirectiveNumber WHERE PlantId = '1201'

SELECT @DirectiveNumber

Tuesday, May 16, 2006

ASP.NET 2.0

WOW,

Well I just deployed my first ASP.NET 2.0. What a difference from 1.x.

I learned that you can deploy by using a publish and precompiled mode that will not cause a slow load the first time a user accesses the site, but the issue with using that is that when you make change you have to redeploy all the .aspx and .dll files again. That kinda sucks.

However, after a little research I found a tool that add-ons from microsoft: http://msdn.microsoft.com/asp.net/reference/infrastructure/wdp/

This feature more reflects the ASP.NET 1.x way of creating dlls

Friday, May 12, 2006

How do I hide a column in my Datagrid if AutoGenerateColumns is set to True?

Question: How do I hide a column in my Datagrid if AutoGenerateColumns is set to True?

Answer: AutoGenerated columns do not appear in the Datagrid's Columns() collection, and so the usual method of hiding a Datagrid column will fail:

'Will NOT work for AutoGenerated columns:
Datagrid1.Columns(1).Visible = False

So the place to handle this is in the ItemDataBound event of the Datagrid:

<asp:DataGrid id="Datagrid1" runat="server" AutoGenerateColumns="True" OnItemDataBound="Datagrid1_OnItemDataBound"/>

Codebehind
Private Sub Datagrid1_OnItemDataBound(s As Object, e As DatagridItemEventArgs)
e.Item.Cells(1).Visible = False
End Sub

Tuesday, May 09, 2006

AUTOEVENTWIREUP .NET

WARNING...

Auto Event Wireup will fire your ASP.NET pages twice be warned.

Monday, May 08, 2006

Parse Error When adding new Web pages to application

I am banging my head on this one... All of my other Web forms work fine but now...

I am getting the following error when adding new Web forms to my application:

I just added simple Web form with Hello World typed on the page.

Server Error in '/XXX.QuipSap.WebUi' Application.



Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Could not load type 'XXX.QuipSap.WebUi.TestForm'.

Source Error:

Line 1: <%@ Page Language="vb" AutoEventWireup="false" Codebehind="TestForm.aspx.vb" Inherits="XXX.QuipSap.WebUi.TestForm"%>
Line 2:
Line 3:

Source File: c:\inetpub\wwwroot\XXX.QuipSap.WebUi\TestForm.aspx Line: 1


SOLUTION:
OK as crazy as a solution that this sounds, but I am not to happy with the solution but it works.

When I create add a new Web form I just remove the inherits part from the first line of the aspx page. If I add labels or buttons and double click on them VS.NET 2003 adds back the inherits and magically (HMM I say magically because if I knew what was fixing it I would not be writting this) fixes the issue.

Parse Error When adding new Web pages to application

I am banging my head on this one... All of my other Web forms work fine but now...

I am getting the following error when adding new Web forms to my application:

I just added simple Web form with Hello World typed on the page.

Server Error in '/XXX.QuipSap.WebUi' Application.



Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Could not load type 'XXX.QuipSap.WebUi.TestForm'.

Source Error:

Line 1: <%@ Page Language="vb" AutoEventWireup="false" Codebehind="TestForm.aspx.vb" Inherits="XXX.QuipSap.WebUi.TestForm"%>
Line 2:
Line 3:

Source File: c:\inetpub\wwwroot\XXX.QuipSap.WebUi\TestForm.aspx Line: 1


SOLUTION:
OK as crazy as a solution that this sounds, but I am not to happy with the solution but it works.

When I create add a new Web form I just remove the inherits part from the first line of the aspx page. If I add labels or buttons and double click on them VS.NET 2003 adds back the inherits and magically (HMM I say magically because if I knew what was fixing it I would not be writting this) fixes the issue.

Parse Error When adding new Web pages to application

I am banging my head on this one... All of my other Web forms work fine but now...

I am getting the following error when adding new Web forms to my application:

I just added simple Web form with Hello World typed on the page.

Server Error in '/XXX.QuipSap.WebUi' Application.



Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Could not load type 'XXX.QuipSap.WebUi.TestForm'.

Source Error:

Line 1: <%@ Page Language="vb" AutoEventWireup="false" Codebehind="TestForm.aspx.vb" Inherits="XXX.QuipSap.WebUi.TestForm"%>
Line 2:
Line 3:

Source File: c:\inetpub\wwwroot\XXX.QuipSap.WebUi\TestForm.aspx Line: 1


SOLUTION:
OK as crazy as a solution that this sounds, but I am not to happy with the solution but it works.

When I create add a new Web form I just remove the inherits part from the first line of the aspx page. If I add labels or buttons and double click on them VS.NET 2003 adds back the inherits and magically (HMM I say magically because if I knew what was fixing it I would not be writting this) fixes the issue.

Parse Error When adding new Web pages to application

I am banging my head on this one... All of my other Web forms work fine but now...

I am getting the following error when adding new Web forms to my application:

I just added simple Web form with Hello World typed on the page.

Server Error in '/XXX.QuipSap.WebUi' Application.



Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Could not load type 'XXX.QuipSap.WebUi.TestForm'.

Source Error:

Line 1: <%@ Page Language="vb" AutoEventWireup="false" Codebehind="TestForm.aspx.vb" Inherits="XXX.QuipSap.WebUi.TestForm"%>
Line 2:
Line 3:

Source File: c:\inetpub\wwwroot\XXX.QuipSap.WebUi\TestForm.aspx Line: 1


SOLUTION:
OK as crazy as a solution that this sounds, but I am not to happy with the solution but it works.

When I create add a new Web form I just remove the inherits part from the first line of the aspx page. If I add labels or buttons and double click on them VS.NET 2003 adds back the inherits and magically (HMM I say magically because if I knew what was fixing it I would not be writting this) fixes the issue.

Sunday, January 29, 2006

Right click command prompt

Here's a handy tip that I got from a co-worker, who found it in the book Microsoft Visual C# .NET Step by Step. It creates a shortcut in the right click context menu of Windows Explorer to open a command prompt in the current directory. When I need to run scripts in a very long directory name, this is very handy.

So here's how you set it up:

Open up windows explorer
Tools -> Folder Options.
File Types Tab
Select the Folder file type
Click Advanced
Click New
For the Action type what ever you want the context menu to display, I used Command Prompt.
For the Application used to perform the action use c:\windows\system32\cmd.exe (note on win2k you will want to specify the winnt directory instead of the windows directory)

You can also use this feature to attach context actions to file types. Or if you want to create a right click open with option for any file type (for instance I like to be able to open any file with notepad, see: my blog entry here.

Friday, January 20, 2006

Arrays

Well I guess it is time to start being a true programmer and master arrays. So what did I learn day one about using arrays.

If you are going to use C# and want a dynamic array you better use the following code... (HINT USE AN ARRAY LIST)

int i = 0;
ArrayList al = new ArrayList();
while (myReader.Read())
{
al.Add(myReader.GetInt32(0));
i = i + 1;
}

Friday, January 13, 2006

Directory .NET Functions

NET Framework Class Library

Directory Members

Moojjoo Blog

SharePoint Stats

Getting Usage Statistics on Sharepoint Portal 2003 Areas
This comes from this microsoft blog



"There are pages available in Windows SharePoint Services that will allow you to obtain usage statistics for WSS Sites. However, this is not the case for Areas in SharePoint Portal Server 2003. There are no built-in hyperlinks in the Admin pages for viewing usage statistics for a give Area.

Does this mean that usage statistics are not available for Areas in SPS 2003? No, it just means that you have to know a backdoor URL to get to the pages that display the stats. Here is the format of the URL:

http://{your portal name}/_layouts/1033/usageDetails.aspx

This URL will take you to a usage statistics page for the Home Area of your portal. (Note: the 1003 is the designator for you language, so it will be different if not using U.S. English).

If you want to look at usage statistics for a Subarea, for instance, News, you would modify the URL to look as follows:

http://{your portal name}/News/_layouts/1033/usageDetails.aspx"


Moojjoo Blog

Wednesday, January 11, 2006

Validating Edits in Grids

When using the Grid Web Controld a lot of times I find myself needing to customize the edit functionality to use validation. The following are the procedures that I use to customize the Data Grid Web Controld.

In order to implement a customization in a datagrid you need to implement a template

<asp:TemplateColumn HeaderText="Gift Amount">
<itemtemplate>
<asp:label id="lblAward_Amount" text='<%# DataBinder.Eval(Container.DataItem, "Gift_Amount", "{0:c}") %>' Runat="server" />
</itemtemplate>
<edititemtemplate>
<asp:textbox ID="txtGift_Amount2" text='<%# DataBinder.Eval(Container.DataItem, "Gift_Amount", "{0:c}") %>' runat="server" />
<asp:regularexpressionvalidator id="Regularexpressionvalidator1" runat="server" ControlToValidate="txtGift_Amount2"
ErrorMessage="Money Values only example 20.00 no commas!" ValidationExpression="\d*.\d{2}"></asp:regularexpressionvalidator></asp:boundcolumn>
</edititemtemplate>
</asp:TemplateColumn>

To access this in the code behind you must using the following:

// This will access the control inside the data grid.
tempGiftAmount = (((TextBox)e.Item.FindControl("txtGift_Amount2")).Text);

Wednesday, December 28, 2005

Inserting Null Values into SQL Server "FINALLY"

After many months of frustration I finally discovered the code to post null values into SQL Server.

cmd.Parameters.Add("@Emp_EID", System.DBNull.Value);

Tuesday, November 01, 2005

Validating Multi-line text boxes in ASP.NET using regular expression validator

Validate Multi-line text box in ASP.NET with Regular Expression

^[\s\S]{0,200}$

200 is the Character count

Thursday, October 20, 2005

Friday, October 07, 2005

Custom Validation

Today I created my first custom validation:

public void TextFilled(object sender, ServerValidateEventArgs e)
{
int counter = 0;
if(DropDownList_Awards.SelectedValue.ToString() == "4" && AwardDesc.Text == "")
{
counter++;
}
e.IsValid = (counter == 0) ? true : false;
}

Hower, I made a bad error: DUH!!!!

on the Button Click event add

if (Page.IsValid)
{

}