Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("-----------STARTING APPLICATION-----------");
            Console.WriteLine("EXECUTING XML VIEW FILE");

            SqlXmlCommand cmd = new SqlXmlCommand("Provider=sqloledb; Data Source=(local);Initial Catalog=TK431Chapter8;UID=sa");

            Console.WriteLine("Loading Updategram");
            cmd.CommandStream = new FileStream("NewLogRecordUpdategram.xml", FileMode.Open, FileAccess.Read);
            cmd.CommandType = SqlXmlCommandType.DiffGram;

            Console.WriteLine("Creating parameters");
            SqlXmlParameter ID = cmd.CreateParameter();
            ID.Name = "@ID";
            ID.Value = "6";

            SqlXmlParameter appName = cmd.CreateParameter();
            appName.Name = "@AppName";
            appName.Value = "CustomerAssistance";

            SqlXmlParameter message = cmd.CreateParameter();
            message.Name = "@Message";
            message.Value = @"<logRecord machine='WebHostingServer' timestamp='2000-01-01T06:00:00Z'>
                     <post eventType='appStart'>
                        <moreInformation>The web server is under attack</moreInformation>
                    </post>
                </logRecord>";

            Console.WriteLine("Executing!");
            cmd.ExecuteNonQuery();

            Console.WriteLine("-----------APPLICATION FINISHED-----------");
            Console.ReadLine();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            FileStream    xmlQuery = new FileStream("updategram.xml", FileMode.Open);
            SqlXmlCommand cmd      = new SqlXmlCommand(connectionString);

            cmd.CommandStream = xmlQuery;
            cmd.CommandType   = SqlXmlCommandType.UpdateGram;
            cmd.ExecuteNonQuery();
            xmlQuery.Close();
        }
Ejemplo n.º 3
0
        public void CleanDatabase()
        {
            SqlXmlCommand command = new SqlXmlCommand(_SqlXmlconnectionString);

            command.CommandType = SqlXmlCommandType.Sql;
            command.CommandText = "delete address;delete Employee";
            SqlXmlParameter param = command.CreateParameter();

            command.ExecuteNonQuery();
        }
Ejemplo n.º 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            StreamReader  reader = File.OpenText(Application.StartupPath + @"\employees.xml");
            SqlXmlCommand cmd    = new SqlXmlCommand(strConn);

            cmd.CommandType = SqlXmlCommandType.DiffGram;
            cmd.CommandText = reader.ReadToEnd();
            cmd.SchemaPath  = Application.StartupPath + @"\employees.xsd";
            cmd.ExecuteNonQuery();
            MessageBox.Show("DiffGram updated to database successfully!");
        }
Ejemplo n.º 5
0
        private void PersistChanges(string serializedEmployees, bool delete)
        {
            SqlXmlCommand command = new SqlXmlCommand(_SqlXmlconnectionString);

            command.CommandType = SqlXmlCommandType.Sql;
            command.CommandText = "exec PersistEmployees ?, ?";
            SqlXmlParameter param = command.CreateParameter();

            param.Value = serializedEmployees;
            SqlXmlParameter param2 = command.CreateParameter();

            param2.Value = delete ? 1 : 0;
            command.ExecuteNonQuery();
        }