Wednesday, September 29, 2010

Delete Windows Service Using DOS

Use command prompt and delete a service using following command:

sc delete < SERVICE name>

To Create

sc create

Note:
If you have space in the file path you need to use quotation marks ("). For example:
sc create "MySQL" binpath= "C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqld.exe"

Setup Outlook Express for Gmail

If you're setting up Outlook Express to work with Gmail for the first time, you'll need to:

Check the below URL for detail or click here

http://mail.google.com/support/bin/answer.py?hl=en&answer=13276


 

Setup Outlook for Gmail

If you're setting up Outlook 2003 to work with Gmail for the first time, you'll need to:

Check the below URL for detail or click here :

http://mail.google.com/support/bin/answer.py?hl=en&answer=13278


 

Monday, September 27, 2010

Check The Temperature Of Your CPU

if your PC keeps crashing for no apparent reason, and if those crashes tend to occur when the machine is busy doing lots of things, there's a pretty good chance that the problem is down to an overheating CPU.  Maybe one of the fans in your system has stopped working, or an air vent is blocked with dust.
To help diagnose such problems, here's a wonderful little Windows utility that tells you the current internal temperature of your CPU.  If the chip has multiple cores, it'll even give you a separate reading for each. And if there are multiple CPUs, that's catered for too.
It runs on Windows XP and above, and supports a wide variety of CPU types from Intel and AMD.  And it's only a 0.5 MB download.  Plus, it's available in 32- and 64-bit versions, including a portable version that can be run  directly without needing to be installed.
The program is called CoreTemp, and you can get it from    www.alcpu.com/CoreTemp.

CoreTemp

Reference URL

Read Data from Excel (VB Code)



Private Sub cmd_browse_Click()
On Error Resume Next
Dim FNum As Integer
Dim txt As Recordset
On Error GoTo FileError
CommonDialog1.CancelError = True
CommonDialog1.Flags = cdlOFNFileMustExist
CommonDialog1.DefaultExt = "xls"
CommonDialog1.Filter = "Excel file|*.xls|*.*"
CommonDialog1.ShowOpen
FNum = FreeFile
pathtxt.Text = CommonDialog1.FileName
Close #FNum
Dim cnExcel As New ADODB.Connection
Dim rs As New ADODB.Recordset

With cnExcel
    .Provider = "Microsoft.Jet.OLEDB.4.0"
    '.ConnectionString = "Data Source=" & App.Path & "\Contact.xls;" & "Extended Properties=Excel 8.0;"
    .ConnectionString = "Data Source='" & pathtxt.Text & "';Extended Properties=Excel 8.0;"

    .Open
End With

Dim strQuery As String
strQuery = "SELECT * FROM [Sheet1$]"
rs.Open strQuery, cnExcel, adOpenStatic, adLockReadOnly

'totaltxt.Text = rs.RecordCount
'MsgBox "Total records: " & rs.RecordCount
'MsgBox "Reading first record..."


'MsgBox "ID: " & rs(i)
'MsgBox "NAME: " & rs(j)
'MsgBox "AGE: " & rs(k)

'MsgBox "Saving into Access..."

Dim cnAccess As New ADODB.Connection
With cnAccess
    .Provider = "Microsoft.Jet.OLEDB.4.0"
    .ConnectionString = "Data Source=" & App.Path & "\temp.mdb;"
    .Open
End With

Dim cmdAccess As New ADODB.Command
cmdAccess.ActiveConnection = cnAccess
If rs.EOF = False Then
On Error Resume Next
Dim i As Integer
For i = 0 To rs.RecordCount
cmdAccess.CommandText = "Insert into table1 values ('" & rs(0) & "','" & rs(1) & "','" & rs(2) & "','" & rs(3) & "','" & rs(4) & "','" & rs(5) & "','" & rs(6) & "','" & rs(7) & "','" & rs(8) & "','" & rs(9) & "','" & rs(10) & "','" & rs(11) & "')"
cmdAccess.Execute
rs.MoveNext
Next
End If
Call totalrecordcount
Call droptb
Call temptb
Call countrecorsd
cmdprint.Enabled = True
cmd_browse.Enabled = False
MsgBox "Data Successfully Transfer to temp.mdb", vbInformation
'Call cmddel_Click
FileError:
   If Err.Number = cdlCancel Then Exit Sub
   End Sub




Sunday, September 26, 2010

Difference between SQL and Oracle

1. Oracle runs on many platforms, SQL on Windows only
2. Oracle includes IFS (Internet File System), Java integration, SQL is more of a pure database
3. Oracle requires client install and setup (Not difficult, but very UNIX-like for Windows users)
4. SQL is #1 in Cost/Performance and overall Performance, although Oracle will refute that
5. Replication is much easier in SQL (I have been at clients where even the Oracle consultant couldn't get it working w/oracle)
6. Failover support in SQL is much, much easier
7. JDBC support is much better in Oracle, although Microsoft is working on it
8. ODBC support in both
9. SQL is ANSI-SQL '92 compliant, making it easier to convert to another ANSI compliant database, theoretically anyway (truth is every database has proprietary extensions). Oracle is generally more proprietary and their main goal is to keep their customers locked-in.
10. SQL natively supports ODBC, OLEDB, XML, XML Query, XML updates. Oracle natively supports proprietary connections, JDBC. Not sure about XML support though.
11. SQL Server is much easier to administrate, with GUI and command- line tools. Most of Oracle is command-line (Back in SQL 6.5 days I had a customer who was so proud that after a day's worth of work he had managed to script his database. I showed him how it was a 3 click operation in SQL ;-)
12. Oracle requires add-ons for transaction monitors, failover, etc. SQL has COM+, uses NT clustering and generally has everything built-in
13. SQL Analysis Services is included (A very powerful OLAP server). For Oracle it is a separate purchase.

Access SQL Server Instance from the network

Whenever we create any SQL instance and after that if we want to access from our network.
We need to setup some setting on Client Machine also! This is  only point that people missed

Now we need to install the Client Network Utility on Client Machine and following setting needs to be done.


·         Open Client Network Utility
·         Go to “Alias” Tab
·         Click on “Add…” Button
·         Just type the Server alias (see eg. ABC-1\111) “ABC-1” is server name and “111” instance name
·         Click “OK”

After applying above you can access your instance(sqlservername\instancename) from network.



 

VB Code for Log or Tracking

Dim LFNum As Integer
Dim PLFName As String
'blnfileopen As Boolean

Public Sub OpenFile()
LFNum = FreeFile
PLFName = App.Path & "\proglog\" & Format(Day(Date), "00") & Format(Hour(Time), "00") & Format(Minute(Time), "00") & Format(Second(Time), "00") & ".txt"
Open PLFName For Output As LFNum
Print #LFNum, "Logging Started at....." & Date; " "; Time
Print #LFNum, ""
'blnfileopen = True
End Sub

Public Sub LogData(msg As String)
'If Not blnfileopen Then OpenFile
Print #LFNum, msg
End Sub

Public Sub closefile()
Print #LFNum, ""
Print #LFNum, "***** Session Close at " & Date; " "; Time; "*****"
Close LFNum
End Sub

Linked Server

---------------------------------------------------------
Create  Linked Server through Scripts  
---------------------------------------------------------

USE [master]
GO
EXEC sp_addlinkedserver
   @server='dsql2k',
   @srvproduct='',
   @provider='SQLNCLI',
   @datasrc='source_name'
 
GO

USE [master]
GO
EXEC master.dbo.sp_serveroption @server=N'dsql2k', @optname=N'rpc', @optvalue=N'true'
GO

EXEC master.dbo.sp_serveroption @server=N'dsql2k', @optname=N'rpc out', @optvalue=N'true'
GO

select * from master.dbo.sysservers
---------------------------------------------------------------------------
 Alternative Script to Create Linked Server and Mapping of Users
---------------------------------------------------------------------------
Use Master
go
EXEC master.dbo.sp_addlinkedserver @server = N'dsql2k', @srvproduct=N'', @provider=N'SQLOLEDB', @datasrc=N'testserver'
GO

EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname = N'dsql2k', @locallogin = N'sa', @useself = N'False', @rmtuser = N'sa', @rmtpassword = N'sa'
GO


 

Saturday, September 25, 2010

SQL Backup Plan with Dynamic file Name

DECLARE @day         VARCHAR(5)
DECLARE @month         VARCHAR(15)
DECLARE @year          VARCHAR(5)
DECLARE @hour          VARCHAR(5)
DECLARE @filename     VARCHAR(500)

SET @day     =   DATENAME(DAY, GETDATE())
SET @month     =   DATENAME(MONTH, GETDATE())
SET @year     =   DATENAME(YEAR, GETDATE())
SET @hour     =   DATENAME(HOUR, GETDATE())
SET @filename = 'D:\DataBase Backup\db_name_' + @day + @month + @year + @hour + '.bak'

Backup Database db_name to Disk = @filename with format   
BACKUP log db_name to disk = @filename with format

Move SQL Server Databases Using Detach and Attach

--How to move SQL Server databases to a new location by using Detach and Attach functions in SQL Server
--Prerequisites
--Note You can determine the name and the current location of all files that a database uses by using the 
sp_helpfile stored procedure

use
go
sp_helpfile
go

--Detach the database as follows:


use master
go
sp_detach_db 'mydb'
go

--Next, copy the data files and the log files from the current location (D:\Mssql7\Data) to the new location (E:\Sqldata).
--Re-attach the database. Point to the files in the new location as follows:

use master
go
sp_attach_db 'mydb','E:\Sqldata\mydbdata.mdf','E:\Sqldata\mydblog.ldf'
go

--Verify the change in file locations by using the sp_helpfile stored procedure:

use mydb
go
sp_helpfile
go

--The filename column values should reflect the new locations.

Friday, September 24, 2010

How to Schedule Programs to Run Automatically

t's often very handy to be able to schedule tasks to run unattended. The classic example is backup. I backup my key data each night at 2.00 a.m. and thankfully I don't have to be there to make it happen. Instead it takes place automatically using the task scheduler built into the backup program.
However, not all programs have an inbuilt task scheduler. In these cases it's still possible to run the program using a scheduling program. In this article we will look at two: Task Scheduler  that comes free with all Windows versions from Windows 98 onwards and a rather more sophisticated freeware product called System Scheduler.


Windows Task Scheduler

Windows inbuilt scheduler is perfect for scheduling programs that don't require any keyboard inputs to run.

Let's explore the use of Windows Task Scheduler by setting up an automated daily task to clean all the junk files off your hard drive. I'll use Windows XP in this example but the technique I'll describe works for Vista and Windows 7 as well though the interface for Windows Task Scheduler is a little different in each case.

The program we will use to do the cleaning is the excellent free utility CCleaner. If you don't have a copy, go grab it now from here: http://www.filehippo.com/download_ccleaner/
After downloading, install the program on your PC. During the installation make sure you un-check the option to install the Yahoo Toolbar, unless, that is, you really want it. After installing CCleaner start the program and check the default cleaning options to make sure these are what you want. For example, if you want to retain your browser history and auto-complete make sure those boxes are unchecked. Once you are happy with the options, shut down CCleaner.
Now start up the Windows Scheduler by clicking Start / Control Panel / Scheduled Tasks / Add Scheduled Task.  Click on Add a Task and this will start the Scheduled Task Wizard. Click and this will bring up a list of programs. Select CCleaner then



Then select Daily and . Then whatever time you want the program to automatically run and . After that, enter your username and passwords followed by . Don't click just yet.

Now we need to use a little trick. If you stop at this point CCleaner will run automatically at the prescribed time but won't actually do any cleaning. It will be just sitting there waiting for you to press some buttons.
To get around this you need to tell CCleaner to run without any user intervention. Thankfully the folks at CCleaner have provided a special command line option to do this.
To add the command line option, check the "Open advanced properties" box in the Task Scheduler Wizard and then . In the "Run" box you should have something that looks like this:
"C:\Program Files\CCleaner\ccleaner.exe"
Now click at the end of this line just after the .exe, leave a space and then type in /AUTO so the complete line now looks like this:
"C:\Program Files\CCleaner\ccleaner.exe" /AUTO
The /AUTO tells CCleaner to run automatically once started and exit automatically when finished which is exactly what you want.

Well that's it! You've now created a scheduled job that will clean your hard drive of unwanted files every night.
If you want to create other scheduled jobs such as backup or defragging your hard drive you can do so in the same way.
Unfortunately, not all programs have command line options like CCleaner that allow automatic running without user input. For these programs to run automatically you need a program that can automate the entry of keystrokes. 


System Scheduler
For more complex task scheduling my top choice is System Scheduler. It does a similar job to Windows Scheduler but additionally it allows you to enter any key-presses required  by a program in order to run.  You can do this by entering into System Scheduler a line containing the keystrokes you want to execute when the program runs.
Lets look at a practical example using DiskKeeper Lite. When you run this program you need to click a few buttons in order to start a defrag job. Usually you would use your mouse to do this clicking but you can also use keystrokes to achieve the same thing ike this:

  • Close the nag screen. This can be done from the keyboard in DiskKeeper by pressing Alt F4
  • Select the menu item "Actions."  This can be done from the keyboard by pressing Alt A
     
  • Select from the Actions menu the item "Defragment." This can be done from the keyboard by pressing the "D" key
In System Scheduler you would do this by entering the string "%{F4}%{A}D" into the "Sendkeys" field within the System Scheduler job setup panel.  Note that in System Scheduler plain keystrokes such  as "D" are entered as you would normally type them but special keystrokes such as Alt  F4 have to be entered using a code like %{F4}. Full details of these special key codes can be found in the System Scheduler help file.

The developer offers a free and a Pro version of System Scheduler. The latter has some useful additional features such as the ability to reboot and run as a service but the free will do for most folks. Furthermore, the free version covers both home and business use. 

Reference URL

An Unusual Way to Reduce Windows Boot Time

My first tip: Clearing the Recent Documents folder to reduce Windows boot time

There are lots of different ways you can reduce Windows boot time but this technique is less well known and on certain PCs can be surprisingly effective.
Windows keeps a list of all the recent documents that you have opened or used and over time the list can grow quite large. Since Windows checks the list at startup, a very large list can increase boot time. Also, you may not always want to have an easily available record of all the documents you have been opening for others to read.
The recent documents folder is handled differently in different versions of Windows but in each case the easiest way to access this folder is from the Start Menu. Here’s the procedure for Windows XP, Vista and Windows 7:

Windows XP
As you probably know, Windows XP has a section of the Start menu called “My Recent Documents”, which displays the last 15 documents that have been opened. However, the number of documents that Windows XP actually keeps track of is usually much larger. The list that is kept is comprised of shortcuts that are stored in the folder \Documents and Settings\{User}\Recent\. (Confusingly, the folder Recent appears as My Recent Documents in Windows Explorer.)
1. Click the Start button
2. Click Run
3. Type “recent” into the box (without the quotes) and click the OK button
4. When the folder opens, you can delete as many items as you wish.

Windows Vista
In Vista, the relevant section of the Start Menu is called Recent Items and the Run line is no longer displayed by default. The folder containing the Recent Items shortcuts is at \Users\{user}\AppData\Roaming\Microsoft\Windows\ Recent\. It can be accessed from the Start Menu in this way:
1. Click the Start button
2. Enter “shell:recent” into the Start Search box (without quotes and with no spaces)
3. In the listing that appears, click shell:recent
4. In the folder that opens, delete as many items as you wish.

Windows 7
In Windows 7, the recently used items have effectively been moved to Jumplists. There is still a folder with all the shortcuts and it is accessed in the same way as for Vista except that the Start Search box is now labeled “Search programs and files.”
1. Click the Start button
2. Enter “shell:recent” into the Search programs and files box (without quotes and with no spaces)
3. In the listing that appears, click shell:recent
4. In the folder that opens, delete as many items as you wish

Other cleaning options
The popular freeware program CCleaner will also completely clear out the Recent folder or allow you to exclude items from deletion.

Reference URL

How to Get to Safe Mode in Windows XP/Vista/7

There are times when it is better to run Windows in what is known as “Safe Mode,” which is a diagnostic setup. Its purpose is to help troubleshoot computer problems by operating with a bare minimum of drivers and Windows components.


Open Safe Mode with the F8 key
All Windows versions can be booted into Safe Mode by this method. Note that it is somewhat tricky to time this procedure and it may take several attempts.
1. Turn on or restart your computer.
2. Hold down the F8 key before the Windows logo appears. If the computer makes a complaining noise, tap the F8 key repeatedly instead of holding it down.
3. If a Windows logo or “Windows starting” appears, wait until Windows loads. Then restart the computer and try pressing  F8 again.
4. Once you are successful, a menu will appear with a number of boot options. Use an arrow key to navigate to “Safe Mode” and press the Enter key.
Trying to get to Safe Mode by using the F8 key can be frustrating and there is another way that uses the System Configuration Utility (msconfig).

System Configuration Utility in Windows XP
1. Open the Start menu and click “Run.”
2. In the Run box, enter “msconfig” (without quotes).
3. Click “OK.”
4. Select the tab “BOOT.INI.”
5. Put a check by the entry /SAFEBOOT. Also click the radio button MINIMAL.
6. Click “Apply” and “OK.”
7. Restart the computer. The system should open in Safe Mode.
When finished using Safe Mode, open msconfig again and remove the check by /SAFEBOOT. Otherwise, you will continue to open in Safe Mode whenever you boot.

System Configuration Utility in Windows 7/Vista
1. Open the Start menu.
2. Enter “msconfig” (without quotes) in the box labeled Start search (Vista) or Search programs and files (Windows 7).
3. Click the entry “msconfig” or “msconfig.exe” shown in the programs list.
4. Select the “Boot” tab.
5. In the “Boot options” section, check “Safe boot.” Also, make sure the radio button “Minimal” is selected.
6. Click “OK’
7. Restart the computer
When you are finished with Safe Mode, go back to msconfig and remove the check by “Safe boot” that was applied in step 5 above.

Reference URL