C
C#4mo ago
Mekasu0124

✅ This is a new set of errors to me

string path = "version.txt";

if (!File.Exists(path))
{
FileStream fs = new(path, FileMode.CreateNew);
fs.Write("1.0.0"); // Cannot convert from 'string' to 'System.ReadOnlySpan<byte>'
}
string path = "version.txt";

if (!File.Exists(path))
{
FileStream fs = new(path, FileMode.CreateNew);
fs.Write("1.0.0"); // Cannot convert from 'string' to 'System.ReadOnlySpan<byte>'
}
I've never seen this error before so I'm not sure how to go about solving it. I did google it though, and found this stack overflow https://stackoverflow.com/questions/47321869/how-do-i-convert-a-c-sharp-string-to-a-spanchar-spant, and tried their solution, but now I get
ReadOnlySpan<T> path = "version.txt"; // Parameters or locals of type 'ReadOnlySpan<T>' cannot be declared in async methods or async lambda expressions

if (!File.Exists(path))
{
FileStream fs = new(path, FileMode.CreateNew);
fs.Write("1.0.0"); // Cannot convert from 'string' to 'System.ReadOnlySpan<byte>'
}
ReadOnlySpan<T> path = "version.txt"; // Parameters or locals of type 'ReadOnlySpan<T>' cannot be declared in async methods or async lambda expressions

if (!File.Exists(path))
{
FileStream fs = new(path, FileMode.CreateNew);
fs.Write("1.0.0"); // Cannot convert from 'string' to 'System.ReadOnlySpan<byte>'
}
I also tried the next comment below it
Span<char> path = "version.txt".AsSpan();
Span<char> path = "version.txt".AsSpan();
and got the same error as the ReadOnlySpan<T> so then I tried the other part of that comment
ReadOnlySpan<char> path = "version.txt".AsReadOnlySpan();

/*
* ".AsReadOnlySpan();"
* 'string' does not contain a definition for 'AsReadOnlySpan' and
* no accessible extension method 'AsReadOnlySpan' accepting a first
* argument of the 'string' could be found (are you missing a using
* directive or an assembly reference?)
*
* "ReadOnlySpan<char> path ="
* Parameters or locals of type 'ReadOnlySpan<T>' cannot be declared in async methods or async lambda expressions
*/

if (!File.Exists(path))
{
FileStream fs = new(path, FileMode.CreateNew);
fs.Write("1.0.0"); // Cannot convert from 'string' to 'System.ReadOnlySpan<byte>'
}
ReadOnlySpan<char> path = "version.txt".AsReadOnlySpan();

/*
* ".AsReadOnlySpan();"
* 'string' does not contain a definition for 'AsReadOnlySpan' and
* no accessible extension method 'AsReadOnlySpan' accepting a first
* argument of the 'string' could be found (are you missing a using
* directive or an assembly reference?)
*
* "ReadOnlySpan<char> path ="
* Parameters or locals of type 'ReadOnlySpan<T>' cannot be declared in async methods or async lambda expressions
*/

if (!File.Exists(path))
{
FileStream fs = new(path, FileMode.CreateNew);
fs.Write("1.0.0"); // Cannot convert from 'string' to 'System.ReadOnlySpan<byte>'
}
and got these errors so I'm just not sure what to do
83 Replies
Mekasu0124
Mekasu01244mo ago
when I look at the Write method, it shows that it's looking for a Write(byte[] buffer, ...) so that's a clue I'd imagine
Mekasu0124
Mekasu01244mo ago
after googling that ohhhh you're absolutely right. I didn't even notice I was using one or the other I need to use stream writer to write to the file
leowest
leowest4mo ago
FileStream requires u to write a buffer to the stream StreamWriter works on top of the stream to facilitate that process allowing you to write strings to it
Mekasu0124
Mekasu01244mo ago
FileStream requires u to write a buffer to the stream
would that be a list a bytes array of files to be used?
leowest
leowest4mo ago
it can be a Span or a byte array yes not byte array of files
Mekasu0124
Mekasu01244mo ago
but the information to/from the file
leowest
leowest4mo ago
so for example
Mekasu0124
Mekasu01244mo ago
while you write out your example
leowest
leowest4mo ago
string path = "version.txt";
string path = "version.txt";
You would encode that to bytes and then write teh resulting buffer
Mekasu0124
Mekasu01244mo ago
what I'm trying to achieve it a bit of automation with the checking for an update. I use the GitHub api for the repo's releases and some C# to download, extract, etc, but the person of the version.txt file is to hold the version of the release I just finished working on, so like when I create the new 1.0.0 release on the repo, I'll then change the version.txt file in my editor to say 1.0.2 and then I'll create another release. I'll manually download the 1.0.0 release onto my desktop and I'll run the executable from there. It'll query the github api and get the version number of the latest release on the repo. If the numbers don't match, then the program will present a screen sayign there is an update 🙂
leowest
leowest4mo ago
string path = "version.txt";
string version = "1.0.2";
var result = System.Text.Encoding.UTF8.GetBytes(version);
using var stream = new FileStream(path, FileMode.CreateNew);
stream.Write(result, 0, result.Length);
string path = "version.txt";
string version = "1.0.2";
var result = System.Text.Encoding.UTF8.GetBytes(version);
using var stream = new FileStream(path, FileMode.CreateNew);
stream.Write(result, 0, result.Length);
Mekasu0124
Mekasu01244mo ago
would I do this like
string path = "version.txt";
byte version = Encoding.ASCII.GetBytes("1.0.0");

if (!File.Exists(path))
{
FileStream fs = new(path, FileMode.Create);
StreamWriter sw = new();
sw.Write(version);
}
string path = "version.txt";
byte version = Encoding.ASCII.GetBytes("1.0.0");

if (!File.Exists(path))
{
FileStream fs = new(path, FileMode.Create);
StreamWriter sw = new();
sw.Write(version);
}
leowest
leowest4mo ago
you dont need StreamWriter in my example but you have the extra load of having ot turn your data into bytes to write it to the stream if u use streamwriter this is how it works
Mekasu0124
Mekasu01244mo ago
I like this. It's nice and simple thank you ❤️
leowest
leowest4mo ago
using var sw = new StreamWriter(path, false);
sw.Write(version);
using var sw = new StreamWriter(path, false);
sw.Write(version);
u see how much simpler it is to write to the file? you can also change the encoding etc if need in regards what you're doing what kind of project are you working on?
Mekasu0124
Mekasu01244mo ago
I'm building a grade book
leowest
leowest4mo ago
because there is or was a visual studio extension
Mekasu0124
Mekasu01244mo ago
it's an avalonia project and right now I'm working on the updater mechanism of the project
leowest
leowest4mo ago
that when you build your project it automatically increases the version number to your manifest
leowest
leowest4mo ago
Increment Version on Build - Visual Studio Marketplace
Extension for Visual Studio - Increment Version on every build according to configureable rules.
Mekasu0124
Mekasu01244mo ago
I remember trying to go that route before programmatically, but it was a headache so I just stuck with having a version file
leowest
leowest4mo ago
I see
Mekasu0124
Mekasu01244mo ago
plus it makes for easy troubleshooting as well. If a user gets an issue with the latest update that causes the update to not work, then in the troubleshooting screen on the repo, there'll be information on how to locate the program, find the version.txt file, and how they can edit the file to change the version number back to a version that they know worked, send the error through the help button at the top of the screen, and I can work on fixing it and push a new update and send them an email back letting them know that they can update then
leowest
leowest4mo ago
I see, I use squirrel for updates I can set afterbuild actions on release that generates the deltas
Mekasu0124
Mekasu01244mo ago
all of that was over my head 😂
leowest
leowest4mo ago
then u just need to add a few lines of code to your app and it will check for updates on startup
using var manager = new UpdateManager("url to check", "appName");
var updateInfo = await manager.CheckForUpdate();
if (updateInfo.ReleasesToApply.Count > 0 && MessageBox.Show($@"A new update is available, version {updateInfo.FutureReleaseEntry.Version}, would you like to update now?", @"Update available!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
executable = Path.Combine(manager.RootAppDirectory, string.Concat("app-", updateInfo.FutureReleaseEntry.Version.Version), appName);
}
using var manager = new UpdateManager("url to check", "appName");
var updateInfo = await manager.CheckForUpdate();
if (updateInfo.ReleasesToApply.Count > 0 && MessageBox.Show($@"A new update is available, version {updateInfo.FutureReleaseEntry.Version}, would you like to update now?", @"Update available!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
executable = Path.Combine(manager.RootAppDirectory, string.Concat("app-", updateInfo.FutureReleaseEntry.Version.Version), appName);
}
its super simple 😛 but yeah just saying squirrel is a cool tool for what you're doing but you probably already have your solution made After build is basically an event you can setup in your csproj so that when you build your app in release mode or debug mode it does something after its done building
leowest
leowest4mo ago
No description
leowest
leowest4mo ago
you have Pre and Post events so before u build and after you build so basically squirel creates a MSI setup file on post build
Mekasu0124
Mekasu01244mo ago
that's pretty cool. I'm going to save the message link of that explanation and on my next project which is a desktop math game, I'll come back, and get your help on setting that up and stuff
leowest
leowest4mo ago
no worries sorry that I ended up adding all this unrelated info hehe 😛 so basically just use StreamWriter for your version file u dont need FileStream for that
Mekasu0124
Mekasu01244mo ago
gotcha. I put your code in, and am fixing to test it. just a moment ok so side question. I am on the newest version of Visual Studio. When I create a new avalonia desktop project now, it gives my project a Project.Desktop that is used to when you press the run button to build and run the application and it gives you just a Project file that you use to build your screens and such in. So like for me, I have a GradeBook.Desktop (target for the green run button) and a GradeBook folder where I build my screens and logic and stuff in. Why did that do that lol Your code works, but since I have to target the GradeBook.Desktop for the green play button so that the project builds and runs for testing, it puts the files that I create and such in the GradeBook.Desktop/bin/Debug/net7.0 folder instead of the GradeBook/bin/Debug/net7.0 folder and that's so annoying lol I'm just wondering why they changed it all. What was wrong with the version before
leowest
leowest4mo ago
well I have never played with avalonia yet let me give it a look
Mekasu0124
Mekasu01244mo ago
I definitely appreciate it
leowest
leowest4mo ago
its ok been meaning to try it to see how different it is from MAUI for mobile which template u used to create your app so I use the same?
Mekasu0124
Mekasu01244mo ago
I tried to do a project in MAUI. I was going through some websites tutorial on it and we built a little math game with it. MAUI for desktop is pretty neat, but for some reason I prefer the much harder stuff like Avalonia
leowest
leowest4mo ago
if we are talking about windows only then I would use WPF instead
leowest
leowest4mo ago
which of these u used for your project so I go the same route
No description
Mekasu0124
Mekasu01244mo ago
No description
No description
No description
No description
leowest
leowest4mo ago
oh reactiveui not sure I will be of much help o nthat but will see communitytoolkit is what im normally use to I see so the other project is a library and Desktop is the actual application so whenever u run it will always deploy everything to desktop it never runs from the library if u notice on the folder GradeBook.Desktop/bin/Debug/net7.0
Mekasu0124
Mekasu01244mo ago
I wanted to do CommunityToolKit but I couldn't figure it out, but I love how easy it is
// ReactiveUI
public string _someString;
_someString = "my string";
public string SomeString
{
get => _someString;
set => this.RaiseAndSetIfChanged(ref _someString, value);
}
// in axaml
<Label Content="{Binding SomeString}" />

// CommunityToolKit
public string _someString;
SomeString = "my string";
// in axaml
<Label Content="{Binding SomeString}" />
// ReactiveUI
public string _someString;
_someString = "my string";
public string SomeString
{
get => _someString;
set => this.RaiseAndSetIfChanged(ref _someString, value);
}
// in axaml
<Label Content="{Binding SomeString}" />

// CommunityToolKit
public string _someString;
SomeString = "my string";
// in axaml
<Label Content="{Binding SomeString}" />
I adore community tool kit
leowest
leowest4mo ago
well with community toolkit
Mekasu0124
Mekasu01244mo ago
right. But this setup only makes sense when you're developing the same application across multiple platforms like Mobile, Web, Desktop, and there's one other. For just a desktop application, it should be stand alone, imo
leowest
leowest4mo ago
// ReactiveUI
public string _someString;
_someString = "my string";
public string SomeString
{
get => _someString;
set => this.RaiseAndSetIfChanged(ref _someString, value);
}
// ReactiveUI
public string _someString;
_someString = "my string";
public string SomeString
{
get => _someString;
set => this.RaiseAndSetIfChanged(ref _someString, value);
}
all that would be just
[ObservableProperty]
string someString;
[ObservableProperty]
string someString;
also u should not make your field public
Mekasu0124
Mekasu01244mo ago
yea forgot that decorator
leowest
leowest4mo ago
so the decorator creates all the above under the hood for u
Mekasu0124
Mekasu01244mo ago
and that's why I like it lol
leowest
leowest4mo ago
anyway back to the topic if u look in the folder
Mekasu0124
Mekasu01244mo ago
So now I've got two goals for my next project 1. Build it using CommunityToolkit instead of ReactiveUI 2. look at that squirrel thing
leowest
leowest4mo ago
GradeBook.Desktop/bin/Debug/net7.0 u will also find a GradeBook.dll that is your GradeBook folder as u say what it does is it ships everything to the Desktop folder as the class library is referenced and needed by the Desktop wrapper
leowest
leowest4mo ago
No description
leowest
leowest4mo ago
as you can see in the references of the Desktop u will see something similar to your GradeBook
Mekasu0124
Mekasu01244mo ago
so basically, if I had the other platforms in here along with the desktop application, Each one of those platforms would be a library that the .Desktop wrapper calls to, or the platform dependent calls to I get what you're saying
leowest
leowest4mo ago
well no they would be like Desktop you only have 1 library with all the views etc
Mekasu0124
Mekasu01244mo ago
so then when I publish, I need to publish to the GradeBook.Desktop/bin/Releases/windows folder
leowest
leowest4mo ago
Desktop is just the wrapper delivering it to the desktop with the correct API for desktop ui etc so if u had mobile, you would have another project targeting android for example let me create one to see
leowest
leowest4mo ago
No description
leowest
leowest4mo ago
but essentially everything goes into GradeBook and only if u have something very platform specific u would handle it in the specific project
Mekasu0124
Mekasu01244mo ago
build in one place, and then call the platform that is needed to run and debug/build
leowest
leowest4mo ago
i.e.: .Android
Mekasu0124
Mekasu01244mo ago
ok so then I feel like I've been doing my publishes wrong. When I go to publish a .exe, I use the publishing wizard. After the wizard, I edit the path for the files, and I always publish it to Project/bin/Releases/net7.0/windows for windows applications. Am I not supposed to do that anymore? LIke now I believe I would publish to GradeBook.Desktop/bin/Releases/net7.0/windows instead?
leowest
leowest4mo ago
well publish is exactly for that purpose to build the app to distribute what we were doing was debuging and running it for development so when u want to publish yes that would be the correct route
Mekasu0124
Mekasu01244mo ago
right. I now have to build an exe so that I can test my updater so I'm confirming where I'm supposed to be publishing to lol ok cool
leowest
leowest4mo ago
u right click the platform u want to publish and do the wizard for it
Mekasu0124
Mekasu01244mo ago
right which is GradeBook.Desktop
leowest
leowest4mo ago
yep
Mekasu0124
Mekasu01244mo ago
wait I said all of that wrong
leowest
leowest4mo ago
when u publish Desktop it will include GradeBook and all its dependencies to it and since Desktop depends on GradeBook any time u publish Desktop it will save GradeBook or ask to save if anything is open and get all the new stuff in it Desktop is nothing without GradeBook other than an empty DI shell
Mekasu0124
Mekasu01244mo ago
right. ok one second and I'll be able to explain when I build my updater and gradebook projects to an exe using the publisher, I then do the following: 1. Right-click GradeBook project and select Add Existing Item 2. Navigate file explorer to find the .exe for the Updater project (this is the project that updates the gradebook project and then relaunched it once finished) 3. Select the Updater.Desktop.exe file and instead of clicking Add, I click the dropdown arrow on Add and select Add As Link 4. In VS, I right-click the added existing item, and change it's properties to Copy If Newer I do the same thing with adding in the GradeBook.Desktop.exe file into the updater project. The flow is: 1. user runs executable for gradebook program 2. gradebook queries the github api for the version number of the latest release 3. If the versions do not match, it displays that an update is available 4. The user selects to start update
// launch updater program
Process pWin = new();
pWin.StartInfo.FileName = "Updater.Desktop.exe";
pWin.Start();

// exit gradebook program
Environment.Exit(0);
// launch updater program
Process pWin = new();
pWin.StartInfo.FileName = "Updater.Desktop.exe";
pWin.Start();

// exit gradebook program
Environment.Exit(0);
The updater program downloads the zip folder for the windows os from the latest release on the repo. It then extracts those contents to a temporary folder. After extraction, it then iterates over all of the files and folders in that temp folder and it checks to see if that file/folder already exists in the gradebook. If it does, delete it from gradebook, move new files from temp to gradebook in its place. Once update is finished, alert the user we're done and relaunching the application.
// launch gradebook program
Process pWin = new();
pWin.StartInfo.FileName = "GradeBook.Desktop.exe";
pWin.Start();

// exit updater program
Environment.Exit(0);
// launch gradebook program
Process pWin = new();
pWin.StartInfo.FileName = "GradeBook.Desktop.exe";
pWin.Start();

// exit updater program
Environment.Exit(0);
so my question is, when I go to link the executables to each project respectively, do I need to link it into GradeBook or GradeBook.Desktop? apologies. I know that's a lot to read. I couldn't think of a better way to explain it
leowest
leowest4mo ago
ok im a bit confused by the first part hahaha
when I build my updater and gradebook projects to an exe using the publisher, I then do the following: Right-click GradeBook project and select Add Existing Item Navigate file explorer to find the .exe for the Updater project (this is the project that updates the gradebook project and then relaunched it once finished) Select the Updater.Desktop.exe file and instead of clicking Add, I click the dropdown arrow on Add and select Add As Link In VS, I right-click the added existing item, and change it's properties to Copy If Newer
you create your updater and u add it to Gradebook? why you could just make it publish to the same folder if u need to ship them both together Well I dont think u need to link anything so long as they are shipped together all u need is the proper code in each project I see 2 scenarios, either u send Updater.exe to the user and if it does not find GradeBook.Desktop.exe it assumes its a new install and install the whole thing 2 scenario would be u ship the whole thing so it install everything together When you run GradeBook it would have some logic to check version, if verion does not match, it would close itself and launch the updater updater would check what it needs to do, do it, replace files, and call Desktop again
Mekasu0124
Mekasu01244mo ago
yea i built my own updater lol
No description
leowest
leowest4mo ago
that's fine you dont want your own app self updating it self as it would be classified as virus so yeah I would probably just give the user the Updater for download and once they run it
Mekasu0124
Mekasu01244mo ago
no it doesnt. updater only updates gradebook. then closes
leowest
leowest4mo ago
and installs and run the main app
Mekasu0124
Mekasu01244mo ago
ok so basically what I was going to do was have 3 projects in 1. Project 1 is the installer that will handle downloading and extracting the zip folder from the github repo and placing the contents in the users Programs folder. Once finished, it'll launch GradeBook.Desktop.exe Project 2 is the updater which will handle updating the project anytime I produce a new release. Unlike the installer and gradebook projects, the updater is built once and used forever. I may go back and optimize it, but that's not going to happen for a while so it'll handle updating the installer and gradebook projects accordingly and once the updates are finished, it relaunches GradeBook.Desktop.exe Project 3 is the grade book program itself which the user uses. When it launches, it checks to see if the version.txt file exists > create if not. Then it checks the versions between the repo's latest release and the text file match. If not, then it presents a window to the user that update exists and asks do they want to update. When they click yes, it closes the GradeBook program, and starts a new process with the Updater.Desktop.exe file
leowest
leowest4mo ago
technically that is 4 projects are u producing Updater as a single file? if so I would just set a Post build event to copy it over to Dekstop publish folder
Mekasu0124
Mekasu01244mo ago
installer (one), updater (two), gradebook (three)? I'm not understanding 4. and yes each project gets published down to its own executable
leowest
leowest4mo ago
ah so you're also doing a separated installer
Mekasu0124
Mekasu01244mo ago
right. There will be a setup.json file that will be added in with that project and the json file will store a boolean value. Once the installer finishes setting up the program, it'll change that stored boolean to a true value so that way the installer only ever runs once. After that initial time, the updater takes over things from there
leowest
leowest4mo ago
your logic there sounds fine dont see anything wrong with that
Mekasu0124
Mekasu01244mo ago
oh ok cool 🙂
cmd.CommandText = @"CREATE TABLE IF NOT EXISTS
[students] (
[Id] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
[FirstName] VARCHAR(2048),
[MiddleName] VARCHAR(2048),
[LastName] VARCHAR(2048),
[AlternateFirstName] VARCHAR(2048),
[AlternateLastName] VARCHAR(2048),
[PhysicalAddress] VARCHAR(2048),
[City] VARCHAR(2048),
[State] VARCHAR(2048),
[Zip] INTEGER,
[County] VARCHAR(2048),
[Country] VARCHAR(2048),
[PrimaryNumber] VARCHAR(2048),
[SecondaryNumber] VARCHAR(2048),
[PrimaryEmail] VARCHAR(2048),
[SecondaryEmail] VARCHAR(2048),
[Birthday] VARCHAR(2048),
[ParentEmail] VARCHAR(2048),
[ParentHomePhone] VARCHAR(2048),
[ParentHomePhone2] VARCHAR(2048),
[ParentCellPhone] VARCHAR(2048),
[ParentCellPhone2] VARHCAR(2048),
[StudentAddress] VARCHAR(2048)
)";

cmd2.CommandText = @"CREATE TABLE IF NOT EXISTS
[staff] (
[Id] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
[FirstName] VARCHAR(2048),
[MiddleName] VARCHAR(2048),
[LastName] VARCHAR(2048),
[AlternateFirstName] VARCHAR(2048),
[AlternateLastName] VARCHAR(2048),
[PhysicalAddress] VARCHAR(2048),
[City] VARCHAR(2048),
[State] VARCHAR(2048),
[Zip] INTEGER,
[County] VARCHAR(2048),
[Country] VARCHAR(2048),
[PrimaryNumber] VARCHAR(2048),
[SecondaryNumber] VARCHAR(2048),
[PrimaryEmail] VARCHAR(2048),
[SecondaryEmail] VARCHAR(2048),
[StudentName] VARCHAR(2048),
[NumberOfStudents] INTEGER,
)";

cmd3.CommandText = @"CREATE TABLE IF NOT EXISTS
[parents] (
[Id] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
[FirstName] VARCHAR(2048),
[MiddleName] VARCHAR(2048),
[LastName] VARCHAR(2048),
[AlternateFirstName] VARCHAR(2048),
[AlternateLastName] VARCHAR(2048),
[PhysicalAddress] VARCHAR(2048),
[City] VARCHAR(2048),
[State] VARCHAR(2048),
[Zip] INTEGER,
[County] VARCHAR(2048),
[Country] VARCHAR(2048),
[PrimaryNumber] VARCHAR(2048),
[SecondaryNumber] VARCHAR(2048),
[PrimaryEmail] VARCHAR(2048),
[SecondaryEmail] VARCHAR(2048),
[StudentName] VARCHAR(2048)
)";
cmd.CommandText = @"CREATE TABLE IF NOT EXISTS
[students] (
[Id] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
[FirstName] VARCHAR(2048),
[MiddleName] VARCHAR(2048),
[LastName] VARCHAR(2048),
[AlternateFirstName] VARCHAR(2048),
[AlternateLastName] VARCHAR(2048),
[PhysicalAddress] VARCHAR(2048),
[City] VARCHAR(2048),
[State] VARCHAR(2048),
[Zip] INTEGER,
[County] VARCHAR(2048),
[Country] VARCHAR(2048),
[PrimaryNumber] VARCHAR(2048),
[SecondaryNumber] VARCHAR(2048),
[PrimaryEmail] VARCHAR(2048),
[SecondaryEmail] VARCHAR(2048),
[Birthday] VARCHAR(2048),
[ParentEmail] VARCHAR(2048),
[ParentHomePhone] VARCHAR(2048),
[ParentHomePhone2] VARCHAR(2048),
[ParentCellPhone] VARCHAR(2048),
[ParentCellPhone2] VARHCAR(2048),
[StudentAddress] VARCHAR(2048)
)";

cmd2.CommandText = @"CREATE TABLE IF NOT EXISTS
[staff] (
[Id] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
[FirstName] VARCHAR(2048),
[MiddleName] VARCHAR(2048),
[LastName] VARCHAR(2048),
[AlternateFirstName] VARCHAR(2048),
[AlternateLastName] VARCHAR(2048),
[PhysicalAddress] VARCHAR(2048),
[City] VARCHAR(2048),
[State] VARCHAR(2048),
[Zip] INTEGER,
[County] VARCHAR(2048),
[Country] VARCHAR(2048),
[PrimaryNumber] VARCHAR(2048),
[SecondaryNumber] VARCHAR(2048),
[PrimaryEmail] VARCHAR(2048),
[SecondaryEmail] VARCHAR(2048),
[StudentName] VARCHAR(2048),
[NumberOfStudents] INTEGER,
)";

cmd3.CommandText = @"CREATE TABLE IF NOT EXISTS
[parents] (
[Id] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
[FirstName] VARCHAR(2048),
[MiddleName] VARCHAR(2048),
[LastName] VARCHAR(2048),
[AlternateFirstName] VARCHAR(2048),
[AlternateLastName] VARCHAR(2048),
[PhysicalAddress] VARCHAR(2048),
[City] VARCHAR(2048),
[State] VARCHAR(2048),
[Zip] INTEGER,
[County] VARCHAR(2048),
[Country] VARCHAR(2048),
[PrimaryNumber] VARCHAR(2048),
[SecondaryNumber] VARCHAR(2048),
[PrimaryEmail] VARCHAR(2048),
[SecondaryEmail] VARCHAR(2048),
[StudentName] VARCHAR(2048)
)";
I'm writing my database logic for creating my relative database. I'm trying to find a good way to link these three tables together through a common variable. For example: The principle receives a new student and they get enrolled. The students information will go into the students table, the students parents information will go in the parents table, and the student will get assigned to a teacher, or number of teachers, and the teachers information already exists for when they were added to the gradebook on hire. So if a teacher needs to see parent/student information or the principle needs to see what teacher is assigned to the student, what's a good way to link these three tables together so that I can just do one database call and have access to the all the information from all 3 tables?
leowest
leowest4mo ago
well that is a question for another topic 😛 u might want to create a separted #help for that or ask in #database and $close this one
MODiX
MODiX4mo ago
Use the /close command to mark a forum thread as answered