Humprey Evangelista Cogay

My Programming Adventures
Connect to SSIS on Named Instance of SQL Server

I am encountering this error on a freshly installed Named Instance SQL Server 2005

"Failed to retrieve data for this request. (Microsoft.SqlServer.SmoEnum)

The SQL Server specified in Integration Services service configuration is not present or is not available. This might occur when there is no default instance of SQL Server on the computer. For more information, see the topic "Configuring the Integration Services Service" in SQL Server 2008 Books Online.

Login Timeout Expired

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2008, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections.

Named Pipes Provider: Could not open a connection to SQL Server [2]. (MsDtsSvr)."

 

after googling I found this blog post from http://www.igregor.net

http://www.igregor.net/post/2009/01/21/Connect-to-SSIS-on-Named-Instance-of-SQL-Server.aspx

Works like a charm =)

 

Posted: 07-26-2010 9:34 PM by Comgen | with no comments
Filed under:
Get the workstations Physical Address (MAC Address)

I currently have a new project and as an additional security I want to get the workstations MAC address and store it in the Log..

Here's my solution which I based somewhere.....

            IPGlobalProperties NetworkProperties = IPGlobalProperties.GetIPGlobalProperties();
            NetworkInterface[] NetworkInterfaceCards= NetworkInterface.GetAllNetworkInterfaces();
            string macAddress = "";
            VeteransBankENT.ApplicationVariables.CurrentHostName = NetworkProperties.HostName;
            VeteransBankENT.ApplicationVariables.CurrentHostName = NetworkProperties.DomainName;

           if (NetworkInterfaceCards == null || NetworkInterfaceCards.Length < 1)
            {
                MessageBox.Show("  No network interfaces found.");
            }
           
            foreach (NetworkInterface adapter in NetworkInterfaceCards)
            {
                if (adapter.NetworkInterfaceType == NetworkInterfaceType.Ethernet && adapter.OperationalStatus == OperationalStatus.Up)
                {
                    IPInterfaceProperties properties = adapter.GetIPProperties(); //  .GetIPInterfaceProperties();
                    PhysicalAddress address = adapter.GetPhysicalAddress();
                    byte[] bytes = address.GetAddressBytes();
                    for (int i = 0; i < bytes.Length; i++)
                    {
                         macAddress  += bytesIdea.ToString("X2");
                         if (i != bytes.Length - 1)
                        {
                            macAddress  +=  "-";
                        }
                    }
                    VeteransBankENT.ApplicationVariables.CurrentHost = macAddress;
                    break;
                }
            }

 

VS 2008 and Ajax - Ajax not working - Web.Config entries missing (Fixed).....

I was trying to upgrade one of my Test Web Applications to use Ajax, After going through the usual procedures of adding a ScriptManager and a UpdatePanel and adding some codes, I tried running my app for the first Time, I found out that my pages are still loading as a whole.

When I tried to check my Web.Config, I found out that my Web.Config lacks the entries related to Ajax. So what I did was I added the Ajax related Web.Config manually and violla my pages now runs perfectly.....

I don't know if this was a bug or I did something which caused my VS not to update my Web.Config.....Any comments guys?

 

Visual Studio 2008 Jquery Intellisense Fails when adding Jquery UI

I've been playing aroung with Jquery for months now but its only recently that I have tested jquery intellisense functionality in Visual Studio 2008

What I have noticed is, Intellisense works perfectly but not until referensing other Jquery Plugins like ui.datepicker.js. the warning message is

Warning    2    Error updating JScript IntelliSense: C:\Users\XXX\Desktop\JqueryExer\Scripts\jquery-1.3.2-vsdoc.js: 'div.childNodes' is null or not an object @ 1487:4    C:\Users\XXX\Desktop\JqueryExer\Pages\MasterPage.master    1    1    C:\...\JqueryExer1\

 

After surfing around I found a solution which is adding an empty file named ui.datepicker-vsdoc.js, so does this mean that for every plugin I have to add a -VSDOC version of that file? sadly as of writing its the only solution that I have browsed.

 

Posted: 06-24-2009 12:25 AM by Comgen | with no comments
Filed under: , , ,
Unify Windows Forms and ASP.NET Providers for Credentials Management

I have coded several Windows Applications using .Net for the bank for the past years and one of the ussual task is to create the Login Form.

I have posted previously one of the solution I use in doing it (Use Membership API in winForms).

Browsing for new things to do I found this link on MSDN which I think is a better article to read Unify Windows Forms and ASP.NET Providers for Credentials Management

 

Hope to hear some comments or better solution from you guys.....

 

 

One Great Tool For Us

I was absent yesterday because I was sick then I thought of formatting my Mobile Computer, after installing all the softwares I needed I figured out that I forgot one important thing. I forgot to save my bookmarks which always saves me minutes of browsing, when ever I stumble upon a problem which I forgot the solution..... So what i did was to look for some utility to at least allow me not to repeat this Stupidity....

I Found this great Plugin for Firefox http://www.foxmarks.com/

I tested it just right now and Wow it really works.. plus there's alot of additional features like sharing and etc.....

 

 

Posted: 09-30-2008 10:44 AM by Comgen | with no comments
Filed under: , , ,
SQL Audit Trail

I was asked by a friend of mine on how to create a trigger that would trace the changes that a user did to a table. So i checked my bookmarks and give him this link

http://www.nigelrivett.net/SQLTriggers/Triggers_2_Creating_Audit_Trails.html

Hope to Get some of your opinions or maybe improvements on the topic inside the link above.

 

God Bless...

Starting Log4Net

One of the task that a developer needs to accomplish is to code a module for logging, and creating it from scratch will take some of your precious time.

 So  to be a little more productive, we can use a tested library like Log4Net.

I have browsed for some pages and found a lot of variations. So putting it all together, here is the routine that i used to do...

Note:

   the configuration file for Log4Net is found on another Config File, not on the App.Config 

 

1. Download Log4net

     http://logging.apache.org/log4net/

2. Extract the downloaded file in your preferred destination

3. Add a Reference to Log4Net.Dll (found inside "bin\net\2.0\release")

4. Create a new Config File named Log4Net.Config and paste the code below

 

<?xml version="1.0" ?>

 

                <log4net>

                                <appender name="FileAppender" type="log4net.Appender.RollingFileAppender">

                                                <file value="c:\log\" />

                                                <appendToFile value="true" />

                                                <datePattern value=".yyyyMMdd." />

                                                <rollingStyle value="Date" />

                                                <param name="StaticLogFileName" value="false" />

 

                                                <layout type="log4net.Layout.PatternLayout">

                                                                <conversionPattern value="%date [%thread] %exception %username %-5level %logger [%property{NDC}] - %message - %identity% newline" />

                                                </layout>

                                </appender>

                                <root>

                                                <level value="ALL"/>

                                                <appender-ref ref="FileAppender"/>

                                </root>

                </log4net>

for more information about the Log4Net Configuration you can visit

http://logging.apache.org/log4net/release/manual/configuration.html

 

------------------------------------------------------------------------------

5. Open AssemblyInfo.Cs and Add the bolded line below just after the last [assembly line

 

[assembly: AssemblyTitle("Log4NetExer1")]

[assembly: AssemblyDescription("")]

[assembly: AssemblyConfiguration("")]

[assembly: AssemblyCompany("")]

[assembly: AssemblyProduct("Log4NetExer1")]

[assembly: AssemblyCopyright("Copyright ©  2008")]

[assembly: AssemblyTrademark("")]

[assembly: AssemblyCulture("")]

[assembly: log4net.Config.XmlConfigurator(ConfigFile = "Log4Net.config", Watch = true)]

 

6. place the following code in the load event of your main Form

private void Form1_Load(object sender, EventArgs e)

        {  

            string log4netconfigfile = Application.StartupPath + @"\log4net.config";

            log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo(log4netconfigfile));

        }

7. And thats it you are ready to log log and log

sample logging

        private void button1_Click(object sender, EventArgs e)

        {

            Logger.Info("Succesfullll");

            Logger.Error("asdasdasd",new DivideByZeroException());

        }

Help =)

Hello IT friends hehehe Help naman po, Post naman a comment or critique about my Shots... Just want to know if there's improvement. Here's my Blog

Http://HumpreyCogay.BlogSpot.Com

Thank you....

SQL versions

Its been months since i have'nt posted anything haha. I was addicted to photography indeed. Http://HumpreyCogay.BlogSpot.Com

Any way i want to share one of my problems then. I've been coding SQL Querries for SQL Server for several years now, but working for the bank we use AS400 DB2 as a main DBMS. The problem here is there are several differences between the 2. SQL Server and DB2.

 Luckily i hava a book titled SQL Cook Book published by O'Reilly.

Here's a sample problem that i have(from the book)

   update e
      set e.sal  = ns.sal,
          e.comm = ns.sal/2
     from emp e,
          new_sal ns
    where ns.deptno = e.deptno

And you cannot use it in DB2, Here's the DB2 Version instead

 update emp e set (e.sal,e.comm) = (select ns.sal, ns.sal/2
                                      from new_sal ns
                                     where ns.deptno=e.deptno)
  where exists ( select null
                   from new_sal ns
                  where ns.deptno = e.deptno )

Now I'm back in the community... Hehehhe

Posted: 04-23-2008 2:44 PM by Comgen | with 1 comment(s)
Filed under: ,
New Hobby

 Canon 40D

 

 Canon 40D

I always admired photography. And as a gift to my self i bought a Canon EOS 40D

        http://www.dpreview.com/reviews/canoneos40d/ 

 Now i can use my own images on my Flash Animations.....

 Any Amateur photographers there? maybe jam tayo hehehe.....

Posted: 12-13-2007 3:49 PM by Comgen | with 6 comment(s)
Filed under: , ,
Use Membership API in Winforms

I usually code my own authentication module in my Windows Application but since i have been playing with Web Applications lately, I thought, maybe there's a way  to use the Membership API inside System.Web on my Windows Applications. So after playing and Googling around i have made it worked.

Below are the procedures  

  1. Use aspnet_regsql.exe (can be found inside C:\WINNT\Microsoft.NET\Framework\v2.0.50727 for VB 2005 Express ) to create your Membership related tables and Stored Procedures, Just follow the on screen procedures, I have tested this with SQL Server 2000.
  2. Create a New Windows Application
  3. Open your App.Config and add the following entries
    <connectionStrings>
        <add name="MySqlConnection"
             connectionString="Server=YOURSERVERNAME; Database=YOURDATABASE; User Id=YOURUSERID; password=YOURPASSWORD"
             providerName="System.Data.SqlClient" />
    </connectionStrings
<system.web>
        <membership defaultProvider="SqlProvider">

            <providers>

                <clear />

                <add name="SqlProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="MySqlConnection"

                   applicationName="MYAPPLICATIONNAME"

                   enablePasswordRetrieval="false"

                   enablePasswordReset="false"

                   requiresQuestionAndAnswer="false"

                   requiresUniqueEmail="false"
                         
               passwordFormat="Hashed" />

            </providers>

        </membership>
    </system.web>
 

                4. Add a reference to System.Web

                5. add an Imports System.Web.Security statement on top of your main form code

                6. To create a new user just use the sample code below

                           Try
                                        Membership.CreateUser("Administrator", "p@ssword1")
                            Catch ex As MembershipCreateUserException
                                        MsgBox(ex.Message)
                            End Try

               7. To authenticate a user use the sample code below

 

                            If Membership.ValidateUser(txtUserId.Text, txtPassword.Text) = True Then
                                    frmMain.Show()                                  
                            Else
                                    ShowError("Invalid Password or UserName")
                            End If  
 

 And thats all....

 Hope this one helps.

 

Sorry if the Code is a little Bit Messy still trying to figure out the best way of pasting Codes....
 

Unraveling the Mysteries of .NET 2.0 Configuration

I attended one of the PHINUG tech talks and listen to one of sir punzies talk last year, I saw his XENO project and have played with the configuration class after. then last week i have stumbled upon this page http://www.codeproject.com/dotnet/mysteriesofconfiguration.asp and found out we can do more.....

 Hope this one helps

 

Posted: 06-29-2007 1:16 PM by Comgen | with no comments
Filed under: ,
Wow JavaScript is Cool

I've been coding Javascript when i was in college and whenever i try to play with Web Apps since my primary role hear at our company is related with Windows Apps.

I've been browsing for something new this afternoon when i stumble upon this

http://msdn.microsoft.com/msdnmag/issues/07/05/javascript/default.aspx

WOW. Javascript is much more cooler than i first thought.

Posted: 05-11-2007 3:59 PM by Comgen | with 2 comment(s)
Filed under:
Notify Users Using PC Sound and Flashing Taskbar

I have projects that our Data Center Use to upload,download and process data for our Systems(AS400,Windows, Unix). Most of the time the Data Center operator will have to do things simultaneously (Physically). So sometimes , a finished processing is not noticed for several minutes (sometimes for more than 30 minutes), Which causes a short delay for the next phase.

So i remembered my college days machine problems. I usually add pc beeps on my apps Startup.

So using the Console.Beep() , Background Worker, and the FlashWindowEx API from PInvoke.Net.  I came out with this.  

Note :

      I added a timer just to simulate an ongoing process.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace PC_Beep
{
   public partial class Form1 : Form
   {
      public Form1()
      {
         InitializeComponent();
      }
   private Boolean StopBeeping;
   [
DllImport("user32.dll")]
   static extern Int32 FlashWindowEx(ref FLASHWINFO pwfi);
   [
StructLayout(LayoutKind.Sequential)]
   public struct FLASHWINFO
   {
      public UInt32 cbSize;
      public IntPtr hwnd;
      public UInt32 dwFlags;
      public UInt32 uCount;
      public UInt32 dwTimeout;
   }


   //Stop flashing. The system restores the window to its original state. 
   public const UInt32 FLASHW_STOP = 0;
   //Flash the window caption. 
   public const UInt32 FLASHW_CAPTION = 1;
   //Flash the taskbar button. 
   public const UInt32 FLASHW_TRAY = 2;
   //Flash both the window caption and taskbar button.
   //This is equivalent to setting the FLASHW_CAPTION | FLASHW_TRAY flags. 
   public const UInt32 FLASHW_ALL = 3;
   //Flash continuously, until the FLASHW_STOP flag is set. 
   public const UInt32 FLASHW_TIMER = 4;
   //Flash continuously until the window comes to the foreground. 
   public const UInt32 FLASHW_TIMERNOFG = 12; 


   public static bool FlashWindowEx(Form frm)
   {
      //Get Window Handle
      IntPtr hWnd = frm.Handle;
      FLASHWINFO fInfo = new FLASHWINFO();
      fInfo.cbSize =
Convert.ToUInt32(Marshal.SizeOf(fInfo));
      fInfo.hwnd = hWnd;
      fInfo.dwFlags = FLASHW_ALL | FLASHW_TIMERNOFG;
      fInfo.uCount =
UInt32.MaxValue;
      fInfo.dwTimeout = 0;
      return (FlashWindowEx(ref fInfo) == 0);
   }

   private void button1_Click(object sender, EventArgs e)
   {
      
timer1.Interval = 5000;
      timer1.Enabled =
true;
   }

   private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
   {
      
while (!StopBeeping)
      {
         
Console.Beep(2000, 500);
         
Console.Beep(1500, 500);
      }
   }

   private void timer1_Tick(object sender, EventArgs e)
   { 
      FlashWindowEx(
this);
      timer1.Enabled =
false
      StopBeeping =
false;
      backgroundWorker1.RunWorkerAsync();
      
MessageBox.Show("Process Done", "Comgen Systems Ltd.", MessageBoxButtons.OK);
      
StopBeeping = true;
   }
  }
}

What happens here is when the timer ellapsed it calls the RunWorkerAsync() method of the Background Worker which will call its DoWork method which contains our code for the PC Beep which will run until the StopBeeping boolean variable is set to true.

Next a message box is shown. And when the user presses OK the StopBeeping variable will be set to True which then will be trapped by our background worker and stop the pc beep.

The FlashWindowsEx Api is used to flash our application in the taskbar.

You can also use the this.Activate to activate your Form...

 

More Posts Next page »