i have stored procedure which have 5 field id ,name,address,number and details.
details is the XML column and i need to save and retrieve that xml column data in window form in xml format.I have done with save data into database and i got stopped in retrieve those data in xml format.
How can i get it in window form ..
any suggestion please..
thank you.
What I have tried:
ALTER PROCEDURE [dbo].[pe_insert]
(
@id int,
@name nvarchar(50),
@addres nvarchar(50),
@number nvarchar(50)
)
AS
BEGIN
If @id=0
BEGIN
insert into people(name,addres,number,details) values(@name, @addres, @number , '<root><name>'+@name+'<address>'+@addres+'</address>
<number>'+@number+'')
END
else
BEGIN
UPDATE people SET
name = @name, addres = @addres, number =@number, details = '<root><name>'+@name+'<address>'+@addres+'</address>
<number>'+@number+'' where id=@id
END
END
GO
AND this is my window form code ...
public Form1()
{
InitializeComponent();
}
private void Save_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=IBM163-PC0DE460;Initial Catalog=people data;Integrated Security=True");
con.Open();
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "pe_insert";
cmd.Parameters.AddWithValue("@id", textBox1.Text);
cmd.Parameters.AddWithValue("@name", textBox2.Text);
cmd.Parameters.AddWithValue("@addres", textBox3.Text);
cmd.Parameters.AddWithValue("@number", textBox4.Text);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("succesfully saved");
}