1. Write a script that inserts a new row into the Customers table for each custo
ID: 3675647 • Letter: 1
Question
1. Write a script that inserts a new row into the Customers table for each customer stored in the NewCustomers.xml file below.
<NewCustomers>
<Customer EmailAddress="izzychan@yahoo.com" Password="" FirstName="Isabella" LastName="Chan"/>
<Customer EmailAddress="johnprine@gmail.com" Password="" FirstName="John" LastName="Prine"/>
<Customer EmailAddress="kathykitchen@sbcglobal.net" Password="" FirstName="Kathy" LastName="Kitchen"/>
</NewCustomers>
To accomplish this, begin by storing the contents of the XML file in a variable of the XML type. Then, you can use an INSERT statement to insert the rows into the Customers table.
***** I can do the inserts scripts i believe. I really need help with storing the contents in a variable of the XML type.
Explanation / Answer
Hi below i have explained the concept of storing the variable with encryption and decryption method in XML type for your reference,
Consider the following example for your understanding,
an application configuration file (App.config) is used to store the settings. Though this file contains other configuration that needs to be shared and/or stored in a revision control system. To separate the credentials from other settings, you can link another configuration file like shown below.
Use the file attribute of appSettings element in the primary application configuration file (App.config):
Add a new XML file to the project and name it ProtectedConfig.config:
Set the Copy to Output Directory property of the file to Copy if newer and the Build Action to Content to have the new configuration file correctly deployed.
To read the settings from the configuration file use ConfigurationManager.AppSettings
You can also leverage Windows Data Protection API to encrypt the password in the XML file.
To encrypt the password use PowerShell ConvertFrom-SecureString cmdlet:
A password encrypted this way can be decrypted by the same Windows account only.
Store the encrypted password to the XML file instead of the plain-text one:
To decrypt the password, use ProtectedData.Unprotect:
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.