Search This Blog

Friday, December 16, 2011

Managing Picasa's database

Picasa 3 uses a large data stored in user data on the primary windows partition.
This is sort of stupid since I installed picasa onto a 1TB drive to store photos yet the index stays on C:\ eating valuable disk space.  Plus its to the size on my C:\ drive where I can no longer defrag it.

Here is a solution to the problem, using Windows XP symbolic links and a tool called Junction from the SysInternals group at Microsoft.

Dear Google:

   Please pay attention to your products.  Storing a large database in User data in Windows is bad form and a mis-use of local application data. THIS IS NOT WHAT MICROSOFT MEANT USER DATA FOR.

Please note, I install SQL server and the databases are not stored as entries in user data \ local application data
because IT IS A DATABASE!

Any way, now that my rant is out of the way here is the good stuff...


Move Picasa Database to Another Location:

'via Blog this'

Uses Junction:

Wednesday, December 7, 2011

Chinthaka's Blog Page: ContextSwitchDeadlock was detected

Chinthaka's Blog Page: ContextSwitchDeadlock was detected: "ContextSwitchDeadlock was detected"

'via Blog this'

Steps to disble this exception in VS 2008.

I was getting this error running some long queries.


ContextSwitchDeadlock was detected
Message: The CLR has been unable to transition from COM context 0x3361c50 to COM context 0x3361dc0 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations.



Thursday, December 1, 2011

Making good use of SQL 2005/2008 Rank() function

Ran into the age old problem of migrating data from one system into a new system  where new system requires a unique row id but the previous system does not.  In the scerario,  I am moving 400,000 records across a linked server from SQL 2000 to SQL 2005/2008.  Generating a rowID per row is expense in any type of cursor or While Loop for 1/2 million records.  Using the 2005/2008 Rank() function I managed to migrate 400,000 records in under 3 minutes with the linked server connection running over internet through my home cable modem connection.  Not too bad at all.

SELECT rank() OVER (ORDER BY fPat.PatientID, fMrn.MRN) as RowID
FROM [FRIS].FRIS_DB.[dbo].tbPatients fPat                 
INNER JOIN MRIS.[dbo].W_PATIENT mPat ON mPat.Pat_Id = fPat.PatientID
INNER JOIN [FRIS].FRIS_DB.[dbo].tbMRN fMrn ON fMrn.PatientID = fPat.PatientID

Monday, November 7, 2011

VS2010 + MVC 2.0 + Javascript != Awesome

Okay, this is not a formula for success.
1) I cannot debug javascript by putting a VS2010 break point due to a bug in the MVC 2/3 that Microsoft admits is there but will not fix.  Has something to do with the fact VS2010 cannot debug silverlight and javascript at the same time and VS2010 mis-identifies what is running with MVC 2/3 framework.  That's just great...
2) Back up plan.... the ever useful alert("I'm hitting this face break point");
3) Plus robust exception handling native to javascript.
4) My love for case sensitive coding scripting languages.

Is Javascript the best we can do for a web UI language?

Given a choice, I'd pick python.

Thursday, October 20, 2011

Enable xp_cmdshell in SQL server 2008

Use t-sql to turn on  xp_cmdshell in SQL server 2008

Run this on the master database.
Source:

EXECUTE SP_CONFIGURE 'show advanced options', 1
RECONFIGURE WITH OVERRIDE
GO
 
EXECUTE SP_CONFIGURE 'xp_cmdshell', '1'
RECONFIGURE WITH OVERRIDE
GO
 
EXECUTE SP_CONFIGURE 'show advanced options', 0
RECONFIGURE WITH OVERRIDE
GO


Monday, October 17, 2011

Google Data API Service names

Why does a company completely screw up a perfectly good web site design? Microsoft has routinely done this over the years for no good reason. Google certainly has done this since it started turn off services. So I am blogging this because Google's API documentation which was decent as GData is become more convoluted. I guess more money does not always make things better.

Also, I would also like to express my disappointment with FireFox version .  Thanks for killing a nice browser forcing me to use Chrome on XP and IE on Windows 7.  Nice job guys!

Source url:

Authentication



What is the service name in ClientLogin for each Data API?



A "service name" is a brief string that the ClientLogin authentication system uses to identify a Google service.
Google APIService name
Google Analytics Data APIsanalytics
Google Apps APIs
(Domain Information & Management)
apps
Google Sites Data APIjotspot
Blogger Data APIblogger
Book Search Data APIprint
Calendar Data APIcl
Google Code Search Data APIcodesearch
Contacts Data APIcp
Content API for Shoppingstructuredcontent
Documents List Data APIwritely
Finance Data APIfinance
Gmail Atom feedmail
Health Data APIhealth
weaver (H9 sandbox)
Maps Data APIslocal
Picasa Web Albums Data APIlh2
Sidewiki Data APIannotateweb
Spreadsheets Data APIwise
Webmaster Tools APIsitemaps
YouTube Data APIyoutube
For more information on the other parameters used in a ClientLogin request, see the ClientLogin documentation.






Friday, October 14, 2011

Dragging and dropping rows between DataGridViews

Okay, I set out to reproduce code I have in VB6 with grids copying rows between grids to C# using DataGridView.
Works great except if more than one row is selected. Found this article below

Turns out MouseDown event unselects all but the row under the mouse cursor. To prevent this, I have to create a new custom control derived from DataGridView and overrride OnMouseDown() to prevent base.MouseDown() from firing if more than one row is selected.

This leaves me thinking...

I hate having to create a custom control every time I want to rid a winform control of a bad behavior buffering or event related. Because this unwanted behavior is almost always found after form design is completed.
But this an epiphany occurred to me about winforms. I should consider creating custom controls for all of the standard controls you are using. Seems like a pain but control creation is easy and then I get much better control of my application rather than setting for Microsoft's default.

This is similar to the earlier epiphany I had concerning docking and anchoring controls, where if you make sure controls are in panels and splitters and then in turn these containers are placed in Flowlayoutpanels or tablelayoutpanels, UI design with WInform because understandable and actually fun.

Too bad, I can't this kind of incite to a dev language and platform before I start a new project.

having trouble with drag-n-drop of multiple items:

'via Blog this'

also http://adamhouldsworth.blogspot.com/2010/01/datagridview-multiple-row-drag-drop.html

c# - How could I Drag and Drop DataGridView Rows under each other? - Stack Overflow

Love stackoverflow.com Found C# Example of drag and drop. Implemented a variant of this solution in less than an hour.

c# - How could I Drag and Drop DataGridView Rows under each other? - Stack Overflow:

Monday, October 3, 2011

Formatting a data bound Textbox for currency

This was surprisingly hard with a simple solution:

Bind textbox to data source and the set the format string on the databinding
Reference: http://social.msdn.microsoft.com

TextBox1.databindings.add("Text",myobject,"myfield",True)
TextBox1.databinding(0).formatstring="c"

Easy once you now the answer! :)

Saturday, September 24, 2011

Open folder to location of a file with C#

Sometimes the simplest things are the hardest for me to remember.

Earlier I had wrote the same code for VB6


string myPath = @"C:\Users\admin\Desktop\fotos";
System.Diagnostics.Process prc = new System.Diagnostics.Process();
prc.StartInfo.FileName = myPath;
prc.Start();

Wednesday, September 14, 2011

Use while loop through table

Needed a solution to loop through a sql resultset without a temp table / table variable / cursor.
Found this question: http://stackoverflow.com/q/1578198/44597

My answer: http://stackoverflow.com/questions/1578198/can-i-loop-through-a-table-variable-in-t-sql/7417780#7417780


declare @id int

        SELECT @id = min(fPat.PatientID)
        FROM tbPatients fPat
        WHERE (fPat.InsNotes is not null AND DataLength(fPat.InsNotes)>0)

while @id is not null
begin
    SELECT fPat.PatientID, fPat.InsNotes
    FROM tbPatients fPat
    WHERE (fPat.InsNotes is not null AND DataLength(fPat.InsNotes)>0) AND fPat.PatientID=@id
    
    SELECT @id = min(fPat.PatientID)
    FROM tbPatients fPat
    WHERE (fPat.InsNotes is not null AND DataLength(fPat.InsNotes)>0)AND fPat.PatientID>@id
        
end    

Tuesday, September 13, 2011

T-SQL Merge Example using a value pair


merge W_Entity_Pool
          using ( SELECT 58 AS entity_typ_cd) AS A
                  ON A.entity_typ_cd = W_Entity_Pool.entity_typ_cd

when matched then
update set pool_seq_num = 5

when not matched then
INSERT(entity_typ_cd,DATA_DOMAIN_ID, pool_seq_num)
values(58,1,5);

Saturday, September 10, 2011

   C# code to add a column to an existing MS Access Table.

Revised  post to correct the horrible code formatting.  Sorry....



public static void AddDAOTableColumn(string MDBfile, string tableName, string ColumnName, TypeCode dataType, Int32? columnSize, bool AutoNumber)
{
try
{
 
EnterProc(System.Reflection.MethodBase.GetCurrentMethod());
dao.DBEngine DBE = new dao.DBEngine();
dao.Database DB = DBE.OpenDatabase(MDBfile, false, false, "");
 
LogValue(string.Format("Opened Database: {0}", DB.Name));
 
dao.TableDef table = DB.TableDefs[tableName];
 
LogValue(string.Format("Found Table: {0}", tableName));
 
bool bAddColumn = true;
 
if (table != null)
{
foreach (dao.Field fld in table.Fields)
{
if (fld.Name == ColumnName)
{
bAddColumn = false;
break;
}
}
}
else
bAddColumn = false;
 
LogValue(string.Format("Table.{0} exists?:{1}", ColumnName, !bAddColumn));
 
if (bAddColumn)
{
dao.DataTypeEnum columnType;
 
switch (dataType)
{
case TypeCode.Boolean:
columnType = dao.DataTypeEnum.dbBoolean;
break;
case TypeCode.DateTime:
columnType = dao.DataTypeEnum.dbDate;
break;
case TypeCode.Int16:
columnType = dao.DataTypeEnum.dbInteger;                            
break;
case TypeCode.Int32:
columnType = dao.DataTypeEnum.dbLong;                            
break;
case TypeCode.Object:
columnType = dao.DataTypeEnum.dbMemo;
columnSize = null;
break;
case TypeCode.String:
if (columnSize <= 255)
columnType = dao.DataTypeEnum.dbText;
else
{
columnType = dao.DataTypeEnum.dbMemo;
columnSize = null;
}
break;
default:
columnType = dao.DataTypeEnum.dbText;
if (columnSize == null)
columnSize = 50;
break;
}
 
dao.Field newfield = new dao.Field();
newfield.Name = ColumnName;
newfield.Type = (short)columnType;
 
if (newfield.Type == (short) dao.DataTypeEnum.dbText)
newfield.AllowZeroLength = true;
 
if (columnSize != null)
newfield.Size = Convert.ToInt32(columnSize);
 
if (AutoNumber)
newfield.Attributes = (int)dao.FieldAttributeEnum.dbAutoIncrField;
 
table.Fields.Append(newfield);
table.Fields.Refresh();
DB.TableDefs.Refresh();
 
LogValue(string.Format("Created Column: {0}", newfield.Name));
 
DB.Close();
 
table = null;
newfield = null;
DB = null;
DBE = null;
}
ExitProc(System.Reflection.MethodBase.GetCurrentMethod());
}
catch (Exception ex)
{
ErrorLog(ex);
}
}


Tuesday, August 30, 2011

Better way to debug a Windows Service

Using  conditional IF & Debugger.Launch()  to debug a windows Service better and effectively.



Sunday, August 28, 2011

C# Code to add a registry Key

Discovered that adding Registry keys is slightly more complicated using C# vs VB6...
Needed to define a user and registry security to a key change....

public static bool AddRegKey(string keyName, string valueName) { try { string user = Environment.UserDomainName + "\\" + Environment.UserName; RegistrySecurity rs = new RegistrySecurity(); rs.AddAccessRule(new RegistryAccessRule(user, RegistryRights.ReadKey | RegistryRights.Delete | RegistryRights.WriteKey | RegistryRights.ChangePermissions, InheritanceFlags.None, PropagationFlags.None, AccessControlType.Allow)); RegistryKey key = Registry.CurrentUser.OpenSubKey(sDRCRegKey,true); key.SetAccessControl(rs); key.SetValue(keyName, valueName); return true; } catch { return false; } }

Thursday, August 11, 2011

Find Stored Procedures referencing a table

Two ways:

SELECT o.object_id, o.name, m.definition
FROM sys.sql_modules m
INNER JOIN sys.objects o ON o.object_id = m.object_id
WHERE m.definition like '%tableName%'

SELECT p.name, c.text FROM syscomments c
JOIN sys.procedures p ON p.object_id=c.id
WHERE c.text LIKE '%tableName%'
ORDER BY p.name

Tuesday, July 5, 2011

How can I lock an application after period of user inactivity?

My post on StackOverFlow.com

I have a fat Windows application written in VB6. User must log into the application to use it. I need to log the user out after a period of inactivity. There are over 100 separate forms with one Main form that is always open after the user logs in, so I am looking for an application solution not a form level solution.

Here is the solution I decided upon. I wanted to document it properly. As this is the approach I had envisioned, it is not my code. Someone smarter than I did awhile ago.
I simply implemented the solution into my application.

The app is an multiple-document interface app.

Private Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
Private Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal nCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDest As Any, pSource As Any, ByVal cb As Long)
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer

Private m_hDllKbdHook As Long

Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function GetCursorPos Lib "user32.dll" (ByRef lpPoint As POINTAPI) As Long


Global variables to hold DateTime last user activity and if mouse and keyboard activity has occurred

Public KeysHaveBeenPressed As Boolean
Public HasMouseMoved As Boolean
Public gLastUserActivity As Date

Code to detect keyboard activity

Public Function HookKeyboard() As Long
On Error GoTo ErrorHookKeyboard
m_hDllKbdHook = SetWindowsHookEx(WH_KEYBOARD_LL, AddressOf LowLevelKeyboardProc, App.hInstance, 0&)
HookKeyboard = m_hDllKbdHook
Exit Function
ErrorHookKeyboard:
MsgBox Err & ":Error in call to HookKeyboard()." _
& vbCrLf & vbCrLf & "Error Description: " & Err.Description, vbCritical, "Warning"
Exit Function
End Function
Public Sub UnHookKeyboard()
On Error GoTo ErrorUnHookKeyboard
UnhookWindowsHookEx (m_hDllKbdHook)
Exit Sub
ErrorUnHookKeyboard:
MsgBox Err & ":Error in call to UnHookKeyboard()." _
& vbCrLf & vbCrLf & "Error Description: " & Err.Description, vbCritical, "Warning"
Exit Sub
End Sub
Public Function LowLevelKeyboardProc(ByVal nCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Static kbdllhs As KBDLLHOOKSTRUCT
If nCode = HC_ACTION Then
'keys have been pressed
KeysHaveBeenPressed = True
End If
LowLevelKeyboardProc = CallNextHookEx(m_hDllKbdHook, nCode, wParam, lParam)
End Function

Code to detect mouse movement:

Public Sub CheckMouse()
On Error GoTo ErrCheckMouse
Dim p As POINTAPI
GetCursorPos p
If p.x <> LastMouse.x Or p.y <> LastMouse.y Then
HasMouseMoved = True
LastMouse.x = p.x
LastMouse.y = p.y
End If
Exit Sub
ErrCheckMouse:
MsgBox Err.Number & ": Error in CheckMouse(). Error Description: " & Err.Description, vbCritical, "Error"
Exit Sub
End Sub



On the Main parent Form:
Added a timer:

Private Sub muTimer_Timer()
CheckMouse
'Debug.Print "MU Timer Fire"
'Debug.Print "Keyboard:" & KeysHaveBeenPressed & " - " & "Mouse:" & HasMouseMoved
If HasMouseMoved = False And KeysHaveBeenPressed = False Then
If DateDiff("m", gLastUserActivity, Now) > gnMUTimeOut Then
muTimer.Interval = 0

Else
'Debug.Print " dT "; DateDiff("s", gLastUserActivity, Now)
End If
Else
HasMouseMoved = False
KeysHaveBeenPressed = False
gLastUserActivity = Now
End If
'Debug.Print " dT "; DateDiff("s", gLastUserActivity, Now)
End Sub

Also on the MainForm load event:

Private Sub MDIForm_Load()
HookKeyboard
end sub

Private Sub MDIForm_QueryUnload(Cancel As Integer, UnloadMode As Integer)
UnHookKeyboard
end sub

Wednesday, June 29, 2011

Remote Desktop Keystrokes

Remote Desktop Keystrokes

I am not even going to pretend to memorize these:

Ctrl+Alt+End = Ctrl+Alt+Del (the only truly required one to know!)

ALT+PAGE UP (Switch between programs from left to right)
ALT+PAGE DOWN (Switch between programs from right to left)
ALT+INSERT (Cycle through the programs in most recently used order)
ALT+HOME (Display the Start menu)
CTRL+ALT+BREAK (Switch the client computer between a window and a full screen)
ALT+DELETE (Display the Windows menu)
CTRL+ALT+Minus sign (-) (Place a snapshot of the entire client window area on the Terminal server clipboard and provide the same functionality as pressing ALT+PRINT SCREEN on a local computer.)
CTRL+ALT+Plus sign (+) (Place a snapshot of the active window in the client on the Terminal server clipboard and provide the same functionality as pressing PRINT SCREEN on a local computer.)

Monday, May 23, 2011

How to create a linked server from a local SQL server instance

I needed to add my local server as a named linked server on my development workstation.
Here is the magic hand shake...

--local linked server
EXEC sp_addlinkedserver
@server='FUSIONRIS',
@srvproduct='',
@provider='SQLNCLI',
@datasrc=''

Thursday, May 19, 2011

Resolving CAPICOM reference for .net project

The following was taken from : http://www.jensign.com/JavaScience/CapiCert/index.html

CAPICOM 2 Interop:
Much of the useful certificate store functionality of cryptoAPI has been encapsulated in CAPICOM. CAPICOM provides advanced capability, including support for pkcs7 signatures, envelopes, encryption, Authenticode signatures and advanced certificate store access. CAPICOM requires an end user component dll installation and registration, and deployment of a .net interop assembly. An interop assembly for CAPICOM can be easily built using:
tlbimp capicom.dll /namespace:CAPICOM /out:Interop.CAPICOM.dll
This is essentially the same command executed by VS.net when the COM reference is added. Note that the interop assembly has explicitly been given the namespace CAPICOM while the assembly is titledInterop.CAPICOM. The simple C# application below is compiled using:
csc /r:interop.capicom.dll FindCertnet.cs
To execute the application, the Interop.CAPICOM.dll assembly must be in the application directory, or if Strong Name signed, can be deployed to the GAC for shared access by other .net applications referencing CAPICOM. The application demonstrates basic certificate store access using CAPICOM. It also demonstrates different ways of using a Certificates enumeration, including the indexer. Casting to the ICertContext interface provides the context that can be used with X509Certificate(IntPtr handle) constructor, although with CAPICOM installed, all the functionality is available from the interop assembly. A few properties of an X509Certificate object are displayed:

Monday, May 16, 2011

Reformatted code examples

When I upgraded by site template, I forgot to re-add div class to format source code.
Code snippet I use is from http://bguide.blogspot.com/

/*
Custom CSS class to display code snippets.
http://bguide.blogspot.com/
2008 Feb 03
*/
.mycode
{
white-space:pre;
font-family:monospace;
font-size:9pt;
line-height: 10pt;
height:auto;
width:auto;
padding:5px;
margin-left:10px;
overflow:auto;
}

How to Implement a wait() in VB6

Here is how I created a Wait() for VB6.
Needed for a project to allow form code to pause while still allowing a 3rd party control to upload a file to a server.

Public Sub Wait(milliseconds As Integer)
Dim dTimer As Double
dTimer = Timer
Do While Timer dTimer + CDbl(milliseconds / 1000)
DoEvents
Loop
End Sub

Thursday, May 12, 2011

Mainstream support phases for .NET

Microsoft has published a new article about .NET 3.x support policy:

Mainstream support phases will end as follows:

.NET 2.0: 4/12/2011
.NET 3.0: 4/12/2011
.NET 3.5: 4/12/2011
.NET 3.5 SP1: 1/13/2015 (part of Windows 7)
.NET 4.0: ? at least 3/31/2015
Beginning with .NET 3.5 SP1, the .NET Framework is considered a Component of the Windows OS. Components follow the Support Lifecycle policy of their parent product or platform.

Wednesday, May 11, 2011

Determine if .net 2.0 framework service packs are installed.

To determine if a service pack is installed on a specific framework version :
- open the registry editor(regedit)
(All versions are listed to the path HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\)
- Look at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\vX.X.XXXXX
(Where the X means the version to check
- Look at the key SP, the value is the service pack installed

In exemple, for the framework 2.0 
Path : HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v2.0.50727
Key SP value : 1

This information means the Framework 2.0 sp1 is installed

Tuesday, May 10, 2011

Windows Password Reset Tool

http://pogostick.net/~pnh/ntpasswd/

  • This is a utility to reset the password of any user that has a valid (local) account on your Windows NT/2k/XP/Vista/Win7 etc system.
  • You do not need to know the old password to set a new one.
  • It works offline, that is, you have to shutdown your computer and boot off a floppydisk or CD or another system.
  • Will detect and offer to unlock locked or disabled out user accounts!
  • There is also a registry editor and other registry utilities that works under linux/unix, and can be used for other things than password editing.

Thursday, May 5, 2011

How to append to a text field in t-sql SQL Server 2005/2008

update
tablename
set
fieldname = convert(nvarchar(max),fieldname) + 'appended string'

Monday, April 11, 2011

How To Use the SHGetKnownFolderPath Function from Vb6

I found the answer and posted in StackOverflow.com
How To Use the SHGetKnownFolderPath Function from Vb6

My answer was derived from http://en.kioskea.net/faq/951-vba-vb6-my-documents-environment-variables.

Determine Windows version via WIN32 API in VB6

'Get Windows Version
Public Declare Function GetVersionExA Lib "kernel32" _
(lpVersionInformation As OSVERSIONINFO) As Integer

Public Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type

Public Function IsVistaOrHigher() As Boolean
Dim osinfo As OSVERSIONINFO
Dim retvalue As Integer
Dim bVista As Boolean

bVista = False

osinfo.dwOSVersionInfoSize = 148
osinfo.szCSDVersion = Space$(128)
retvalue = GetVersionExA(osinfo)

If osinfo.dwPlatformId = 2 Then
If osinfo.dwMajorVersion = 6 Then
bVista = True
End If
End If
IsVistaOrHigher = bVista
End Function

Friday, April 8, 2011

Multiple Cursor Example

DECLARE @IPaddress nvarchar(40)
DECLARE @PartnerName nvarchar(40)
DECLARE @AllMessageCodes nvarchar(200)
DECLARE @MessageCode nvarchar(10)

DECLARE @Partners TABLE
(
IPAddress nvarchar(40),
PartnerName nvarchar(40),
AllMessageCodes nvarchar(200)
)


DECLARE cur CURSOR FOR
select distinct p.IPaddress, p.PartnerName
from tbHL7Partners p
inner join tbHL7MessageMapHeader MMH on p.PartnerID = MMH.PartnerID
inner join tbHL7MessageMapDetail MMD on MMH.MsgMapHeaderID = MMD.MsgMapHeaderID
inner join tbcdHL7Messages M on MMD.MessageID = M.MessageID
where p.PartnerDeleted = '0' and mmh.Active = '1' and mmd.[On] = '1'

OPEN cur
FETCH NEXT FROM cur INTO @IPaddress, @PartnerName
WHILE (@@FETCH_STATUS = 0)
BEGIN

SET @AllMessageCodes=''

DECLARE curMessages CURSOR FOR
select M.MessageCode
from tbHL7Partners p
inner join tbHL7MessageMapHeader MMH on p.PartnerID = MMH.PartnerID
inner join tbHL7MessageMapDetail MMD on MMH.MsgMapHeaderID = MMD.MsgMapHeaderID
inner join tbcdHL7Messages M on MMD.MessageID = M.MessageID
where p.PartnerDeleted = '0' and mmh.Active = '1' and mmd.[On] = '1'
and p.IPaddress =@IPaddress and p.PartnerName=@PartnerName
GROUP BY p.IPaddress, p.PartnerName, M.MessageCode

OPEN curMessages
FETCH NEXT FROM curMessages INTO @MessageCode
WHILE (@@FETCH_STATUS = 0)
BEGIN

SET @AllMessageCodes = @AllMessageCodes + ' ' + @MessageCode
--SELECT @MessageCode

FETCH NEXT FROM curMessages INTO @MessageCode
END
CLOSE curMessages
DEALLOCATE curMessages

INSERT INTO @Partners(IPAddress, PartnerName, AllMessageCodes)
SELECT @IPaddress, @PartnerName, @AllMessageCodes

FETCH NEXT FROM cur INTO @IPaddress, @PartnerName
END
CLOSE cur
DEALLOCATE cur

Friday, March 4, 2011

INSERT IDENTITY syntax

Piece of SQL knowledge that I can't seem to keep in my brain...




SET IDENTITY_INSERT table ON

SET IDENTITY_INSERT table OFF


Now to Reseed the Identity column in a table


DBCC CHECKIDENT (table, reseed, newseedvalue)


Friday, February 25, 2011

Download Windows XP Reskit Tools

Download Windows XP Reskit Tools: "Download the Windows XP Support Tools (12.5mb)"

Provides the InstSrv.exe utility to add and remove services

How to remove damaged Windows Service

from url

I have successfully used this with: XP and 2003.

you can also use command prompt and delete a service using following command:
sc delete < SERVICE name>

or to create, simply type
sc create
Update:
If you have space in the file path you need to use quotation marks ("). For example:
sc create "MySQL" binpath= "C:\Archivos de programa\MySQL\MySQL Server 5.1\bin\mysqld.exe"

Thursday, February 10, 2011

Map current folder location as a local drive.

@echo off
subst V: /D
subst V: "%CD%"
subst
PAUSE

Wednesday, February 9, 2011

VB6 Manifest File Follow-Up

Okay, it turns out following the advice in the previous post can produce a valid Windows 7.  Turns the problem was my version number in the manifest file did not match the actual version of the App.exe.  (Stupid stupid mistake).

So here is the manifest file I created. It was too much trouble to convert my manifest file (being XML to something that I can display in blogger, File is Manifest.txt in my BlogFiles folder on skydrive.

Thursday, January 27, 2011

My quest for Windows 7 manifest file for a VB6 exe

So, I am currently running a common problem trying to deploy a Vb6 application written and developed for Windows 2000/XP into the Vista/Win2008/Windows 7 world.

Problems
#1 - User Access Control - I get prompted by Windows about I do not know anything about this program are you sure you want to allow this.

#2 - Run as Administrator requirement:  Under compatibility for the Application short-cut, enabling run as Admin.  Turns out my project is creating and storing session and user in Program Files\App Folder\ in sub folders.  Which is being discouraged by Microsoft in Windows 7.

Possible Solutions:
#1 - On workstation after deployment, Run application with Run as Adminstrator turned on.
        This is an okay workaround but requires every workstation to be touched.
#2 - Use on a manifest file to set the execution permission to Administrator
        Alots and alots of discussions on the web and StackoverFlow.
        Found this gem Manifest creation tool - http://www.vbforums.com/showthread.php?t=606736
      
        Downloaded it.  I was able to create an apparently correct manifest file but  it did not work.
        Still trying to find out why.  
        Related post - http://stackoverflow.com/questions/4489165/vb6-manifest-not-working-on-windows-7/4496389#4496389

 My question if any wants to answer it and earn big big karma points....
What is the best solution to force a VB6 application to run as Administrator premissions
    - Is it really possible for VB6 and Windows 7?
    - Is the problem with session data in ..\Program Files\My App\  really the whole issue?
  
Any advice will be welcomed.  Email: gary.Kindel@gmail.com

Thanks

Tuesday, January 18, 2011

Installing webservice on WIn2008

Flexera Software - Knowledge Base: "Q200236: IIS support for Windows 2008 and Vista SP1

Reviewed installer script, worked

Needed Installshield2008 update to support Windows 2008


- Sent using Google Toolbar"

How do I get a verbose log? - Flexera Software Community

How do I get a verbose log? - Flexera Software Community: "You can create verbose logs for InstallScript MSI projects by launching the setup with the following command line:
setup.exe /verbose'C:\PathToLog\LogFile.log'

You can also enable the Windows Installer logging policy in the registry, however, the resulting output will be multiple log files instead of a single log, and some information from the script engine will not be logged.

- Sent using Google Toolbar"