This blog is most useful for Software Engineers, Database Administrators, QA and etc.
Oct 28, 2008
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 16, 2008
Formatting Numbers/Leading zeros. - .NET C#
Formatting Numbers/Leading zeros. - .NET C#: "input.ToString().PadLeft(length, Convert.ToChar('0'))"
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);
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);
Subscribe to:
Posts (Atom)