Typically you have a model class that represents the data. Here's one:
public class Computer
{
public string SerialNumber {get; set;}
public string Name {get; set;}
public List<string> InstalledSoftware {get; set;}
}
Now that you have a class that can represent the data, it's just a matter of saving or serializing it. You don't have access to a SQL Server database. That's fine. There's other options. You can store it in a structured file format. CSV is not good for this, as you might have multiple pieces of InstalledSoftware per computer, and it's hard to properly handle that with CSV. But other text based formats such as XML and JSON are perfect for this. You can also use "NoSQL" type databases such as MongoDB or RavenDB. You may also be able to use SQLite, which is very lightweight.
Let's start off with some sample data.
List<Computer> computers = new List<Computer>();
computers.Add(new Computer(){
SerialNumber="ABC123",
Name="BOB-LAPTOP",
InstalledSoftware = new List<string>(){
"Notepad", "Visual Studio", "Word"
}
});
computers.Add(new Computer(){
SerialNumber="XYZ456",
Name="JASON-WORKSTATION",
InstalledSoftware = new List<string>(){
"Notepad++", "Visual Studio Code", "Word"
}
});
computers.Add(new Computer(){
SerialNumber="LMN789",
Name="NANCY-SURFACE3",
InstalledSoftware = new List<string>(){
"Outlook", "PowerPoint", "Excel"
}
});
Then it's just a matter of saving the data. Let's try with XML:
var xmlSerializer = new XmlSerializer(typeof(Computer));
using(var stringWriter = new StringWriter())
{
using (var xmlWriter = XmlWriter.Create(stringWriter))
{
xmlSerializer .Serialize(writer, computers);
var xml = stringWriter.ToString();
File.WriteAllText(Server.MapPath("~/App_Data/computers.xml"));
}
}
Or with JSON:
var serializer = new JavaScriptSerializer();
var json = serializer.Serialize(computers);
File.WriteAllText(Server.MapPath("~/App_Data/computers.json"));
Using MongoDB:
var client = new MongoClient(connectionString);
var server = client.GetServer();
var database = server.GetDatabase("ComputerDB");
var computerCollection= database.GetCollection<Computer>("Computers");
foreach(var computer in computers)
{
computerCollection.Insert(computer);
}
Note, I have not tested this code. There's likely bugs. My goal is to give you a starting point, not necessarily 100% working code. I haven't serialized XML in a while and I typically use JSON.NET instead of the built in JavaScriptSerializer.
Also note that if there's any possibility that two users might access the data at the same time, you'll need to take care with the XML and JSON approaches to avoid two people trying to write to the file at once. That's where MongoDB would be better, but you'll have to install the server software somewhere.