(With sa sa),Chosse Database from Initial Catalog.Click Ok.
9.Select all tables,click Next.
Learn And Development is a kind of blog where some issues has been solved.I gone through those issue and manage myself to solve.I know reader must be benefited if they go through on it.
How to create xml
To create xml we need to do following steps=>
1)First include the name i)System.Xml ii)System.IO iii)System.Text.
2)create writer object
| >XmlTextWriter writer = new XmlTextWriter(Server.MapPath("xml/userInfo.xml"), Encoding.UTF8); |
| In Server.MapPath we specify the path where we would like to create xml file. |
| statr to write by writer.WriteStartDocument(); |
| writer.WriteStartElement("userInfo"); this specify strat element with element userInfo |
| writer.WriteElementString("urlReferrer", "none");this specify sub element with element urlReferrer and value none |
| writer.WriteAttributeString("timeVisited", DateTime.Now.ToString());this specify a element attribute with timeVisited |
| writer.WriteEndElement(); this specify end of a element |
| writer.WriteEndDocument(); this specify end of a document. |
| writer.Close(); this specify close of a document. |
Using Triggers In SQL Server /Implementing Trigger In SQL Server
A trigger is used to execute a bach of sql code when a specific event is fired. There are two types of trigger
1>AFTER TRIGGER.
2>INSTEAD TRIGGER.
AFTER TRIGGER is used after a specific event fired.An AFTER trigger is a trigger that gets executed automatically before the transaction is committed or rolled back.
A trigger which gets executed automatically in place of triggering actions i.e., INSERT, DELETE and UPDATE is called an INSTEAD OF trigger.INSTEAD OFtriggers gets executed automatically before the Primary Key and the Foreign Key constraints are checked, whereas the traditional AFTER triggers gets executed automatically after these constraints are checked.
How to execute TRIGGER
First Open the Enterprice manager
1)Start -> Programs -> Microsoft SQL Server -> Enterprise Manager.
2)Expand Sql Server Group->Expand Database->Click on Tables .

3)Right click on the table and choose All Tasks -> Manage Triggers.This will open the trigger properties window, which allows us to create a new trigger:

The syntaxt of the Create Trigger is shown bellow.
1)An example of fire TRIGGER After an INSERT
CREATE TRIGGER [rndTrigger_insert] ON [dbo].[rnd_store_procedure]
FOR INSERT
AS
DECLARE @FName VARCHAR(255)
DECLARE @LName VARCHAR(255)
DECLARE @Address VARCHAR(255)
DECLARE @StoredID BIGINT
SELECT @StoredID = (SELECT PKID FROM Inserted)
SELECT @FName = (SELECT FName FROM Inserted)
SELECT @LName = (SELECT LName FROM Inserted)
SELECT @Address = (SELECT Address FROM Inserted)
INSERT INTO rnd_trigger (StoredID,FName,LName,Address) VALUES (@StoredID,@FName,@LName,@Address)
In the above example it is shown rndTrigger object is created and it is fired when data inserted into table rnd_store_procedure.
When the TRIGGER is fired data also inserted into table rnd_trigger.
2) An example of fire TRIGGER After an DELETE.
CREATE TRIGGER [rndTrigger_delete] ON [dbo].[rnd_store_procedure]
FOR DELETE
AS
DECLARE @PKID BIGINT
DECLARE @Status BIT
SELECT @PKID = (SELECT PKID FROM Deleted)
SELECT @Status = (SELECT Status FROM Deleted)
if(@Status = 1)
BEGIN
RETURN
END
DELETE FROM rnd_trigger WHERE StoredID = @PKID
In the above example it is shown rndTrigger object is created and it is fired when data deleted from table rnd_store_procedure.
When the TRIGGER is fired it is checked the deleted record status is true or false.
If deleted record status is false then corresponding record also deleted from rnd_trigger.
3) An example of fire TRIGGER After an UPDATE.
CREATE TRIGGER [rndTrigger_update] ON [dbo].[rnd_store_procedure]
FOR UPDATE
AS
DECLARE @PKID BIGINT
DECLARE @FName VARCHAR(255)
DECLARE @LName VARCHAR(255)
DECLARE @Address VARCHAR(255)
IF NOT UPDATE(FName) AND NOT UPDATE(LName)
BEGIN
RETURN
END
SELECT @PKID = (SELECT PKID FROM Inserted)
SELECT @FName = (SELECT FName FROM Inserted)
SELECT @LName = (SELECT LName FROM Inserted)
SELECT @Address = (SELECT Address FROM Inserted)
UPDATE rnd_trigger set FName = @FName,LName = @LName,Address = @Address
WHERE StoredID = @PKID
In the above example it is shown rndTrigger object is created and it is fired when rnd_store_procedure is updated.
When the TRIGGER is fired it is checked the FName AND LName from record weather being modified or not.If record is being modified then record from table rnd_trigger also modified.
public string getName
{
get
{
return Name;
}
set
{
Name = value;
}
}
public string getName()
{
get
{
return Name;
}
set
{
Name = value;
}
}
But C# provides a built in mechanism called properties to access private data member
The general form of declaring a property is as follows.
<acces_modifier> <return_type> <property_name>
{
get
{
}
set
{
}
}
Above program can be modifies with a property X as follows.
using System;
class MyClass
{
private int x;
public int X
{
get
{
return x;
}
set
{
x = value;
}
}
}
class MyClient
{
public static void Main()
{
MyClass mc = new MyClass();
mc.X = 10;
int xVal = mc.X;
Response.Write(xVal);//Displays 10
}
}
We have to rember that a property should have at least one accessor either set or get .The set accessor has a free variable available in it called value, which gets created automatically by the compiler. We can't declare any variable with the name value inside the set accessor.
The following program shows a class with a static property.
using System;
class MyClass
{
private static int x;
public static int X
{
get
{
return x;
}
set
{
x = value;
}
}
}
class MyClient
{
public static void Main()
{
MyClass.X = 10;
int xVal = MyClass.X;
Response.Write(xVal);//Displays 10
}
}
Note:Static property can access only other static members of the class. Also static properties are invoking by using the class name.
The properties of a Base class can be inherited to a Derived class.
using System;
class Base
{
public int x ;
public int X
{
get
{
return x+1;
}
set
{
x =value;
}
}
}
class Derived : Base
{
}
class MyClient
{
public static void Main()
{
Derived d1 = new Derived();
d1.X = 10;
Response.Write(d1.X);//Displays 'Base SET Base GET 11'
}
}
The above program is very straightforward. The inheritance of properties is just like inheritance any other member.
A Base class property can be polymorphicaly overridden in a Derived class. But remember that the modifiers like virtual, override etc are using at property level, not at accessor level.
using System;
class Base
{
public virtual int X
{
get
{
Console.Write("Base GET");
return 10;
}
set
{
Console.Write("Base SET");
}
}
}
class Derived : Base
{
public override int X
{
get
{
Console.Write("Derived GET");
return 10;
}
set
{
Console.Write("Derived SET");
}
}
}
class MyClient
{
public static void Main()
{
Base b1 = new Derived();
b1.X = 10;
Response.Write(b1.X);//Displays 'Derived SET Derived GET 10'
}
}
If the abstract class contains only set accessor, we can implement only set in the derived class.
The following program shows an abstract property in action.
using System;
abstract class Abstract
{
public abstract int X
{
get;
set;
}
}
class Concrete : Abstract
{
public override int X
{
get
{
Response.Write(" GET");
return 10;
}
set
{
Response.Write(" SET");
}
}
}
class MyClient
{
public static void Main()
{
Concrete c1 = new Concrete();
c1.X = 10;
Response.Write(c1.X);//Displays 'SET GET 10'
}
}
The properties are an important features added in language level inside C#. They are very useful in GUI programming. Remember that the compiler actually generates the appropriate getter and setter methods when it parses the C# property syntax.
usage: Sqlcmd [-U login id] [-P password]
[-S server] [-H hostname] [-E trusted connection]
[-d use database name] [-l login timeout] [-t query timeout]
[-h headers] [-s colseparator] [-w screen width]
[-a packetsize] [-e echo input] [-I Enable Quoted Identifiers]
[-c cmdend] [-L[c] list servers[clean output]]
[-q "cmdline query"] [-Q "cmdline query" and exit]
[-m errorlevel] [-V severitylevel] [-W remove trailing spaces]
[-u unicode output] [-r[0|1] msgs to stderr]
[-i inputfile] [-o outputfile] [-z new password]
[-f <codepage> | i:<codepage>[,o:<codepage>]] [-Z new password and exit]
[-k[1|2] remove[replace] control characters]
[-y variable length type display width]
[-Y fixed length type display width]
[-p[1] print statistics[colon format]]
[-R use client regional setting]
[-b On error batch abort]
[-v var = "value"...] [-A dedicated admin connection]
[-X[1] disable commands, startup script, environment variables [and exit]]
[-x disable variable substitution]
[-? show syntax summary]