1
Answer

using the xmlReader for xml for auto in ms sql server

littlesun69

littlesun69

21y
4.8k
1
I've got three records in my database in MS Sql Server 2000 and when I query the records the 1st and last records show up in my xml. Is there any reason why the 2nd record is not showing up? Here's my code: using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.Data.SqlClient; using System.Xml; namespace web_test_net.for_xml_auto { /// /// Summary description for xml. /// public class xml : System.Web.UI.Page { protected System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1; protected System.Data.SqlClient.SqlCommand sqlSelectCommand1; protected System.Data.SqlClient.SqlCommand sqlInsertCommand1; protected System.Data.SqlClient.SqlCommand sqlUpdateCommand1; protected System.Data.SqlClient.SqlCommand sqlDeleteCommand1; protected System.Data.SqlClient.SqlConnection sqlConnection1; protected string xmlstring; protected XmlReader xmlreader; private void Page_Load(object sender, System.EventArgs e) { sqlConnection1.Open(); xmlreader = sqlDataAdapter1.SelectCommand.ExecuteXmlReader(); while (xmlreader.Read()) { xmlstring += xmlreader.ReadOuterXml(); } //Response.ContentType = "text/xml"; //Response.Write("" + xmlstring + ""); Response.Write("test="+xmlstring); sqlConnection1.Close(); } and my sql command is: select * from test for xml auto If anyone can I would be much appreciated. Thanks in advance!
Answers (1)
2
Nilesh Shah
NA 22.3k 215k 7y
here is an example
 
you may have to change according to your table:
  1. CREATE TRIGGER trg_Update_Qty  
  2.    ON  Stock   
  3.    AFTER UPDATE  
  4. AS   
  5.     UPDATE Stock SET Keterangag = 0 FROM inserted WHERE inserted.qty = 0 and inserted.kode_barang = Stock.kode_barang  
  6. GO 
 please mark the answer as accepted if it satisfies your question
Accepted
1
Nilesh Shah
NA 22.3k 215k 7y
I assume you want to delete the data in the last column from table when qty = 0.
 
write a trigger on that table in check if qty=0, then delete data in last column i.e. set it to 0
0
Amrul Hakim
NA 19 1.2k 7y
you can show me example code?
Next Recommended Forum