Dec 17, 2008

How to get week name in sql:sql/sql2005

CREATE FUNCTION dbo.DayOfWeek_fn(@dtDate DATETIME)
RETURNS VARCHAR(10)
AS
BEGIN
DECLARE @rtDayofWeek VARCHAR(10)
DECLARE @weekDay INT
-- Here I have subtracted 7 For keeping Sunday as the First day
-- like wise for Monday we need to subtract 2 and so on
SET @weekDay = ((DATEPART(dw,@dtDate)+@@DATEFIRST-7)%7)
SELECT @rtDayofWeek = CASE @weekDay
WHEN 1 THEN 'Sunday'
WHEN 2 THEN 'Monday'
WHEN 3 THEN 'Tuesday'
WHEN 4 THEN 'Wednesday'
WHEN 5 THEN 'Thursday'
WHEN 6 THEN 'Friday'
WHEN 7 THEN 'Saturday'
END
RETURN (@rtDayofWeek)
END
GO

Oct 28, 2008

How to get an Identity value with SQL Server 2005 - .NET at 9.400 ft above sea level

How to get an Identity value with SQL Server 2005 - .NET at 9.400 ft above sea level

Create Table in SQL Server 2005 Using C# and SQL Server Management Objects (SMO) - Code Generation

Create Table in SQL Server 2005 Using C# and SQL Server Management Objects (SMO) - Code Generation

MS SQL 2005 identity lost new database - Database Journal Forums – Database Forum for Access, DB2, SQL, Oracle & More

creating a TABLE

CREATE TABLE [dbo].[TbTest](
[id_TbTest] [int] IDENTITY(1,1) NOT NULL PRIMARY KEY CLUSTERED ,
[Title] [varchar](100) NULL,
) ON [PRIMARY]


when looking at the Column Properties in MS Server Management Studio you can get :
Identity Specification = Yes
(Is Identity) = Yes
Increment = 1
Seed = 1

now if you want to make a copy of that database, importing data and tables

you will get :
Identity Specification = No
(Is Identity) = No

Solution

"It is impossible alter column to type IDENTITY directly, but you can do it in few steps:

ALTER TABLE [dbo].[TbTest] ADD
[id1_TbTest] [int] IDENTITY(1,1) NOT NULL PRIMARY KEY CLUSTERED;
ALTER TABLE [dbo].[TbTest] DROP COLUMN [id_TbTest];
EXEC sp_rename '[TbTest].[id1_TbTest]', 'id_TbTest', 'COLUMN';"

Oct 17, 2008

spot printing in c#

using System.Drawing.Printing;
using System.Drawing;
using System.IO;

namespace WindowsApplication1
{

public partial class Form3 : Form
{
private System.ComponentModel.Container components;
private System.Windows.Forms.Button printButton;
private Font printFont;
private StreamReader streamToPrint;
PrintDocument printDocument1 = new PrintDocument();


public Form3()
{
InitializeComponent();

printDocument1.PrintPage += printDocument1_PrintPage;
}

private void printButton_Click(object sender, EventArgs e)
{
using (PrintDialog pd = new PrintDialog())
{
if (pd.ShowDialog() == DialogResult.OK)
printDocument1.PrinterSettings = pd.PrinterSettings;
printDocument1.Print();
}


void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
Font objFont=new Font ("Microsoft Sans Serif", 10F);//sets the font type and size
float fTopMargin = e.MarginBounds.Top;
float fLeftMargin = 50;//sets left margin
float fRightMargin = e.MarginBounds.Right - 150;//sets right margin
string employee_id = String.Concat("EMPLOYEE ID:- ", comboBox2.Text);//prints EMPLOYEE ID:- and text in combobox2
string employee_name = String.Concat("EMPLOYEE NAME:- ", textBox8.Text);

e.Graphics.DrawString(employee_id, objFont, Brushes.Black, fLeftMargin, fTopMargin);

fTopMargin += objFont.GetHeight() * 2;//skip two lines

e.Graphics.DrawString(employee_name, objFont, Brushes.Black, fLeftMargin, fTopMargin);

objFont.Dispose();

e.HasMorePages = false;
}

Oct 7, 2008

Multi Column ListView Control

Multi Column ListView Control: C#,VB.net

Dim str(5) As String
Dim itm As ListViewItem
str(0) = 'Rob Machy'
str(1) = '100 North Ave'
str(2) = 'Business Manager'
str(3) = '89,000'
str(4) = 'Development'
itm = New ListViewItem(str)



c#:

string[] str=new string [2] ;
ListViewItem lsv;
str[0] = dtItems.Rows[i]["Prefix"].ToString();
str[1] = dtItems.Rows[i]["Priority"].ToString();
ListViewItem itm =new ListViewItem(str);
LstVU.Items.Add(itm);

Aug 26, 2008

Procedure to export a text file with both comma and quote delimiters in Excel

Procedure to export a text file with both comma and quote delimiters in Excel

Procedure to export a text file with both comma and quote delimiters in Excel

Procedure to export a text file with both comma and quote delimiters in Excel

Exporting crystal report as PDF and sending via email as attachment - Filename Issue? : Crystal Reports for Visual Studio : Visual Studio : MSDN Forums

Exporting crystal report as PDF and sending via email as attachment - Filename Issue? : Crystal Reports for Visual Studio : Visual Studio : MSDN Forums: "Dim repdoc As New CrystalDecisions.CrystalReports.Engine.ReportDocument()

Dim diskOpts As New CrystalDecisions.Shared.DiskFileDestinationOptions()

Dim ExpOpts As CrystalDecisions.Shared.ExportOptions

Dim MailOpts As New CrystalDecisions.Shared.MicrosoftMailDestinationOptions()

repdoc = Me.CrystalReport11

repdoc.Load('C:\Documents and Settings\User\My Documents\Visual Studio 2005\Projects\WindowsApplication3\WindowsApplication3\CrystalReport1.rpt')

ExpOpts = repdoc.ExportOptions

With ExpOpts

.ExportDestinationType = CrystalDecisions.[Shared].ExportDestinationType.MicrosoftMail

.ExportFormatType = CrystalDecisions.[Shared].ExportFormatType.PortableDocFormat

End With

With MailOpts

.MailMessage = 'Message'

.MailToList = 'enter email adress here'

.MailSubject = 'Attached is a PDF file - .net Export test '

End With

ExpOpts.DestinationOptions = MailOpts

Try

repdoc.Export()

Catch err As Exception

MessageBox.Show(err.ToString())

End Try"

Crystal Report question : Crystal Reports for Visual Studio : Visual Studio : MSDN Forums

Crystal Report question : Crystal Reports for Visual Studio : Visual Studio : MSDN Forums

Windows Drivers Downloads

Windows Drivers Downloads:dlls download

Crystalreport Tutorials' Sample Code Directory

Tutorials' Sample Code Directory

In this online help, the tutorials provide detailed step procedures that guide you through the completion of complex tasks. The tutorials are also available as completed sample code. See Tutorials.

If you have installed Crystal Reports with the default settings and file paths, sample code is in the directories shown below.

Crystal Reports version
Path to tutorials' sample code
Crystal Reports 11
C:\Program Files\Business Objects\Crystal Reports 11\Developer Files\Help\En\CR_NET_SDK_Tutorial_Sample_Code.zip
Crystal Reports for Visual Studio 2005
C:\Program Files\Microsoft Visual Studio 8\Crystal Reports\Samples\en\Code\TutorialSampleCodeProjects.msi
Crystal Reports Basic for Visual Studio 2008
C:\Program Files\Microsoft Visual Studio 9.0\Crystal Reports\Samples\En\Code\

Aug 14, 2008

PZ10! Jokes - Technical fault

PZ10! Jokes - Jokes Site

How to search a directory and getting the directory path to connection string : c#

private void ResetConnectionString()
        {
            string dbDir = this.GetDBDirectory()+  @"\JSNorthWind.MDB";
            this.nWindConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + dbDir + ";";

        }
        private string GetDBDirectory()
        {
            System.IO.DirectoryInfo currentDirectory = new System.IO.DirectoryInfo(Application.ExecutablePath).Parent;
            
            while (currentDirectory!=null)
            {
                System.IO.DirectoryInfo[] childDirectories = currentDirectory.GetDirectories();
                foreach(System.IO.DirectoryInfo childDir in childDirectories)
                {
                    if(childDir.Name=="Data")
                    {
                        return childDir.FullName;
                    }
                }
                currentDirectory = currentDirectory.Parent;
            }
            return "";
        }

Send instant messages to your online friends http://uk.messenger.yahoo.com

Jul 25, 2008

Jul 7, 2008

keypress in C# - VBForums

keypress in C# - VBForums

C# .NET TextBox KeyPress event to "filter" the input keys

C# .NET TextBox KeyPress event to "filter" the input keys

KeyPressEventArgs.KeyChar Property (System.Windows.Forms)

KeyPressEventArgs.KeyChar Property (System.Windows.Forms)

C# - RESOLVED: Messagebox Issue In C# Windows App | DreamInCode.net

C# - RESOLVED: Messagebox Issue In C# Windows App | DreamInCode.net

Visual C# .NET - Other things to do with the Message Box

Free C# Tutorials
Visual C# .NET - Other things to do with the Message Box

C# ( C Sharp) AIO: A Collection of 59 Bestsellers

Expert C# Business Objects Second Edition
Code:

Visual C# Recipes A Problem Solution Approach
Code:

Learning C Sharp 2nd Edition
Code:

C Sharp for Dummies
Code:

Visual C Sharp Express Edition Starter Kit
Code:

Programming C Sharp
Code:

Visual C Sharp A Developer’s Notebook
Code:

Pro C# and the .NET 2.0 Platform
Code:

Thomson Beginning C Sharp Game Programming
Code:

Course Technology PTR Beginning C# Game Programming
Code:

Elsevier Inc C# 2.0 Practical Guide For Programmers
Code:

C sharp Cookbook
Code:

C# Language Specification
Code:

C Sharp Threading Handbook
Code:

Course Technology PTR Beginning C# Game Programming
Code:

Dissecting a C# Application Inside SharpDevelop
Code:

The MIT Press C# Precisely
Code:

Elsevier Inc Network programming .NET with C# and VB.NET
Code:

Sams Teach Yourself the C# Language in 21 Days
Code:

Expert Service Oriented Architecture in C# Using the Web Services Enhancements 2
Code:

Microsoft Visual C Sharp Dot Net Unleashed
Code:

Professional C# Third Edition
Code:

C Sharp Design Patterns A Tutorial
Code:

Essential Asp Net With Examples In C Sharp
Code:

C Sharp and dotNET Framework The C Perspective
Code:

Windows Forms Programming in C#
Code:

The C# Programming Language
Code:

A Programmer’s Introduction to C#
Code:

C# for Java Developers
Code:

A Programmer e2 80 99s Guide to ADO.NET in C#
Code:

Database Programming with C#
Code:

Pearson C# Primer A Practical Approach
Code:

Microsoft C Sharp Programming for the Absolute Beginner
Code:

Data Entry and Validation with C# and VB .NET Windows Forms
Code:

Professional C# Design Patterns Applied
Code:

Sybex Mastering ASP.NET with C#
Code:

OOP with Microsoft Visual Basic .NET and Microsoft Visual C# Step By Step
Code:

Hungry Minds C# COM Programming
Code:

C# Bible
Code:

C Sharp Network Programming
Code:

Programming C# 2nd Edition
Code:

Teach Yourself Microsoft Visual C Sharp.NET In 24 Hours
Code:

Code:
Application Development Using C Sharp and .NET

Code:

C Sharp Class Design Handbook Coding Effective Classes
Code:

Syngress C# .net Web Developers Guide
Code:

Programming Microsoft Windows with C#
Code:

Syngress C# for Java Programmers
Code:

Premier Press Microsoft C# Professional Projects
Code:

Hungry Minds C# Your visual blueprint for building .NET applications .
Code:

Teach Yourself C# in 24 Hours
Code:

Sybex Visual C# ASP.NET Programming
Code:

Manning Windows Forms Programming with C#
Code:

Professional C Sharp 2nd Edition
Code:

Course Technology PTR Microsoft C# Programming For The Absolute Beginner
Code:

Sybex Mastering C Sharp Database Programming
Code:

C# How To Program
Code:

User Interfaces in C# Windows Forms and Custom Controls
Code:

C# How To Program
Code:

Advanced C# Programming
Code:

Jun 28, 2008

SQL-SCRIPT eSnips Folder

www.esnips.com: They are providing 5GB free storage facility. This is my web storage also, you can download Self Hypnosis and Relaxation Machine, SQLToolbelt, Sinhala Fonts, rapidshare.de downloader, power iso 3.2+crack, Lyrics for english songs, HiddenDesktopInclKeyMaker, Foot Reflexology, font tamil, deskman-powertoysetup, AtomicAlarmClockCracked, uif2iso, RSDirect_Download_v1.14, Password_hacker_BBs, npp.4.8.2.Installer, FancyLogonDesktop-1.0.2, Best_Hacking_Tools_-85in1- and you can run SQl SCRIPTS IN VB/vb.net

Jun 23, 2008

Calling Win32 Api from C# - csharp

Though .Net classes are vast and versatile at time you will have to resort to Win32 API calls for accomplishing certain tasks.

The following code shows a simple example of invoking a Win32 api.

The best way to use Win32 apis is to encapsulate it in a class module.
The namespace for COM interop is System.Runtime.InteropServices.
The method name should have DllImport attribute specifying the name of the dll. Here the dll is user32. Other dlls are Gdi and Kernel.

using System;
using System.Collection.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void cmdtam_Klik(object sender, EventArgs e)
{
string cstr;
cstr = "data source=jery;initial catalog=latihan;uid=sa;pwd=sri";
SqlConnection con1 = new SqlConnection(cstr);
con1.Open();
SqlCommand com1 = new SqlCommand();
com1.Connection = con1;
com1.CommandType = CommandType.Text;
com1.CommandText = "select * from customer"
DataSet ds1 = new DataSet();
SqlDataAdapter adp1 = new SqlDataAdapter(com1);
adp1.Fill(ds1,"customer");
grd1.DataMember = "customer";
con1.Close();
}
}
}

Dislay Data on datagrid - csharp

using System;
using System.Collection.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void cmdtam_Klik(object sender, EventArgs e)
{
string cstr;
cstr = "data source=jery;initial catalog=latihan;uid=sa;pwd=sri";
SqlConnection con1 = new SqlConnection(cstr);
con1.Open();
SqlCommand com1 = new SqlCommand();
com1.Connection = con1;
com1.CommandType = CommandType.Text;
com1.CommandText = "select * from customer"
DataSet ds1 = new DataSet();
SqlDataAdapter adp1 = new SqlDataAdapter(com1);
adp1.Fill(ds1,"customer");
grd1.DataMember = "customer";
con1.Close();
}
}
}

Writing to EventLog - csharp

//Add to the textbox's KeyPress event
private void txtBox_KeyPress(object sender, KeyPressEventArgs e)
{
if (!System.Text.RegularExpressions.Regex.IsMatch(e.KeyChar.ToString(), "\\d+"))
e.Handled = true;
}

Numbers-Only Textbox - csharp

//Add to the textbox's KeyPress event
private void txtBox_KeyPress(object sender, KeyPressEventArgs e)
{
if (!System.Text.RegularExpressions.Regex.IsMatch(e.KeyChar.ToString(), "\\d+"))
e.Handled = true;
}

SQL Server 2005 Express Edition Feature Tour

SQL Server 2005 Express Edition Feature Tour

Microsoft SQL Server: What's New in SQL Server 2005

Microsoft SQL Server: What's New in SQL Server 2005

Microsoft SQL Server: Top 30 Features of SQL Server 2005

Microsoft SQL Server: Top 30 Features of SQL Server 2005: "Discover how SQL Server 2005 will benefit you with the new and enhanced abilities and features described on this page."

Introduction to Service Broker

Introduction to Service Broker:Sql server2005

WebGyver - Tools and Resources for Successful Web Design, Web Development, Web Applications and Web Business Marketing

WebGyver - Tools and Resources for Successful Web Design, Web Development, Web Applications and Web Business Marketing

Ajaxload - Ajax loading gif generator

Ajaxload - Ajax loading gif generator: Animation Generator

After needed an animated loading .gif image for a recent Ajax application I did some quick Google searching and came across a fantastic site: http://www.ajaxload.info/

Ajaxload allows you to generate your own animated Ajax loading images with a few simple click. Starting from a number of animation templates you can then choose a background and foreground colour for your new loading .gif. After 30 seconds of playing around, see some of my examples below:

Ajax loader

Ajax loader

Ajax loader

Fantastic, yet simple. This is the way all websites you should be, well done Ajaxload.

Jun 17, 2008

SQL, database, informix, oracle, SQL Server,Free source code for the taking. Over five million lines of programs.

SQL, database, informix, oracle, SQL Server,Free source code for the taking. Over five million lines of programs.

.Net Programming and Tutorials - CoderSource.net

.Net Programming and Tutorials - CoderSource.net : C#

Scrolling Text on a Form using label control

Scrolling Text on a Form using label control:C#

C# .Net Delegates and events

C# .Net Delegates and events

Using Error Provider Control in Windows Forms and C#

Using Error Provider Control in Windows Forms and C#

Executing external applications using Process class

Executing external applications using Process class: C#

Sending emails in C#

Sending emails in C#

Creating custom windows forms in C# with images

Creating custom windows forms in C# with images

Creating a Splash Screen in C#

Creating a Splash Screen in C#

Google Answers: Microsoft Visual C# Method: External

Google Answers: Microsoft Visual C# Method: External: grab text from outside exe

Win32 Window Handler in C#

Win32 Window Handler in C#: This is an extension of the WindowHandler-class I posted 2 weeks ago. This one is able to close, minimize, maximize and "normalize" windows of external applications.

Finding and Listing Processes in C#

Finding and Listing Processes in C#

ASP 101 - Samples

ASP 101 - Samples

Freelance Programming

Freelance Programming

How to AutoSize the DropDown portion of a ComboBox

How to AutoSize the DropDown portion of a ComboBox

Reading and Writing XML Documents

Reading and Writing XML Documents

Auto create database connection string using INI by c#

Auto create database connection string using INI by c#