how to insert the multipe records in sql server with xml data
while inserting multiple records at a same time in a single transaction without failure (eg: bulk booking cinema tickets) means how to do this. for that inserting datas in sql server via xml is better.By using this we can also stop the transaction failure.................
The following example shows how to insert the multiple records using xml data
CREATE TABLE [dbo].[empinfo](
[eno] [int] NULL,
[ename] [varchar](50)
)
Stored procedure:
Create Procedure sp_InsertEmp
@in_XML Text
AS
Begin
DECLARE @XMLHandle AS INTEGER
Declare @temp table
(empno int,
empname varchar(20)
)
----------------------------------------------------------------
-- Initialize the XML for Processing
----------------------------------------------------------------
EXECUTE sp_xml_preparedocument
@XMLHandle OUTPUT
, @in_XML
INSERT @Temp
(
empno,
empname
)
SELECT
XMLInput.eno,
XMLInput.ename
FROM OPENXML(@XMLHandle,'NewDataset/employee',2)
WITH
(
eno int,
ename varchar(20)
)as XMLInput
----------------------------------------------------------------
-- Close the XML
----------------------------------------------------------------
EXECUTE sp_xml_removedocument @XmlHandle
insert into empinfo(eno,ename)
select empno,empname from @temp
End
--execute stored procedure
exec sp_InsertEmp
'<NewDataset>
<employee>
<eno>101</eno>
<ename>sidhu</ename>
</employee>
</NewDataset>'
Related Question :
1) how to insert the multiple records using c# and sqlserver
2) how to To Send Multiple Rows At Once Into A Stored Procedure
3) Work with XML Data Type in SQL Server 2005 from ADO.NET 2.0
The following example shows how to insert the multiple records using xml data
CREATE TABLE [dbo].[empinfo](
[eno] [int] NULL,
[ename] [varchar](50)
)
Stored procedure:
Create Procedure sp_InsertEmp
@in_XML Text
AS
Begin
DECLARE @XMLHandle AS INTEGER
Declare @temp table
(empno int,
empname varchar(20)
)
----------------------------------------------------------------
-- Initialize the XML for Processing
----------------------------------------------------------------
EXECUTE sp_xml_preparedocument
@XMLHandle OUTPUT
, @in_XML
INSERT @Temp
(
empno,
empname
)
SELECT
XMLInput.eno,
XMLInput.ename
FROM OPENXML(@XMLHandle,'NewDataset/employee',2)
WITH
(
eno int,
ename varchar(20)
)as XMLInput
----------------------------------------------------------------
-- Close the XML
----------------------------------------------------------------
EXECUTE sp_xml_removedocument @XmlHandle
insert into empinfo(eno,ename)
select empno,empname from @temp
End
--execute stored procedure
exec sp_InsertEmp
'<NewDataset>
<employee>
<eno>101</eno>
<ename>sidhu</ename>
</employee>
</NewDataset>'
Related Question :
1) how to insert the multiple records using c# and sqlserver
2) how to To Send Multiple Rows At Once Into A Stored Procedure
3) Work with XML Data Type in SQL Server 2005 from ADO.NET 2.0
How to backup all sql server 2005 databases
Backup all sql server 2005 Database using Script
DECLARE @name VARCHAR(50) -- database name DECLARE @path VARCHAR(256) -- path for backup files DECLARE @fileName VARCHAR(256) -- filename for backup DECLARE @fileDate VARCHAR(20) -- used for file name
SET @path = 'C:\Backup\'
SELECT @fileDate = CONVERT(VARCHAR(20),GETDATE(),112)
DECLARE db_cursor CURSOR FOR
SELECT name FROM master.dbo.sysdatabases WHERE name NOT IN ('master','model','msdb','tempdb')
OPEN db_cursor FETCH NEXT FROM db_cursor INTO @name
WHILE @@FETCH_STATUS = 0 BEGIN
SET @fileName = @path + @name + '_' + @fileDate + '.BAK'
BACKUP DATABASE @name TO DISK = @fileName
FETCH NEXT FROM db_cursor INTO @name END
CLOSE db_cursor DEALLOCATE db_cursor
How to validate Numeric Decimal Values using c#
Decimal validation mostly used utility in the software application ..........
The Below sample code is done the numeric validation exactly.it doesn't allow the double dot in numeric values...........
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
NumericDecimalValidation(sender,e);
}
public void NumericDecimalValidation(object Sender, KeyPressEventArgs e)
{
if (char.IsDigit(e.KeyChar) || e.KeyChar.ToString() == "." || char.IsControl(e.KeyChar))
{
if (((TextBox)Sender).Text.IndexOf(".") != -1 && e.KeyChar.ToString() == ".")
e.Handled = true;
else
e.Handled = false;
}
else
e.Handled = true;
}
The Below sample code is done the numeric validation exactly.it doesn't allow the double dot in numeric values...........
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
NumericDecimalValidation(sender,e);
}
{
if (char.IsDigit(e.KeyChar) || e.KeyChar.ToString() == "." || char.IsControl(e.KeyChar))
{
if (((TextBox)Sender).Text.IndexOf(".") != -1 && e.KeyChar.ToString() == ".")
e.Handled = true;
else
e.Handled = false;
}
else
e.Handled = true;
}
Creating pagination for asp.net repeater
Check user name Availability Using Asp.net and Jquery
How to Check user name Availability Using Asp.net ,Jquery and Json ?
This Application is used to check the user name availability Asynchronously and without affect the page postback . It is done by using the little help of jquery to post the data on Change event to another page.In that page checking the username checking functionality and finally return the confirmation message.
This functionality id really helpful for user registration page.I provide the sample in a easy manner and i hope this is helpful to your development ...............
Find and count the no words using Generic Collections Dictionary
Find the no of word occurences
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
class CountWords
{
public void get()
{
string words = "The C# is Very Cool! The Best";
string[] splitWords=words.Split(' ');
Dictionary
foreach (string str in splitWords)
{
if (dic.ContainsKey(str))
{
dic[str] = dic[str] + 1;
}
else
{
dic.Add(str, 1);
}
}
foreach (KeyValuePair
{
Console.WriteLine(var.Key + ":" + var.Value);
}
}
static void Main()
{
CountWords obj = new CountWords();
obj.get();
Console.ReadLine();
}
}
How to create Autocomplete textbox using Asp.net and Jquery
Auto Complete TextBox Jquery,Json,Asp.net
what is Autocomplete ?
A feature that suggests text automatically based on the first few characters that a user types
I'm googling for autocomplete using Jquery and Asp.net .finally i got a nice article regarding this but the example is provided in php .Then after sometime i migrated the code into Asp.net with Generic handler and with the help of jquery and json .. This will make a asynchronous call to the server side, with no post back