L
Lucky Hyena
Guest
I am programming a dental records database manager. My program asks a user whether it wishes to create a new file or open an existing one on startup. Regardless of either option, the program will then split the string of the directory of the file, and the actual name of the file into separate strings: fileDirectory and fileName. It then passes on these variables, and an empty ADOX catalog to other routines which are used to create different tables within the file (should it be a new one) and then populate three different DataGridView objects with these tables, one for each. The problem comes when I wish to save changes to a file.
I wish to do this with a button:
Private Sub saveBtn_Click(sender As Object, e As EventArgs) Handles saveBtn.Click
End Sub
Whenever I run the routine to create tables for the file, I would like to run an if statement to check if:
1. The file exists
2. If the function has been run before
If these are met I will run code to append the tables to the file, thus saving the changes:
databaseCatalog.Tables.Append(appointmentsTable)
databaseCatalog.Tables.Append(patientsTable)
databaseCatalog.Tables.Append(xraysTable)
I am sure that these objectives I can achieve. However, in order to actually save the file, the user must indicate that they wish to do so, and here comes the tricky part. I wish to call the function that calls the aforementioned if statement, so that I can run the code to save the file. However, I need to pass a catalog into the function which is:
databaseCatalog.Create("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & fileDirectory & fileName)
And my button cannot use fileDirectory or fileName as these variables are not defined within it. As a result, my button cannot pass the appropriate catalog that will allow me to append my tables; if I try to use an empty catalog I get an error that states 'Object is no longer valid'. Is there anything I can do to pass the variable that contains the catalog into the button? Or a way around this? Thanks.
Continue reading...
I wish to do this with a button:
Private Sub saveBtn_Click(sender As Object, e As EventArgs) Handles saveBtn.Click
End Sub
Whenever I run the routine to create tables for the file, I would like to run an if statement to check if:
1. The file exists
2. If the function has been run before
If these are met I will run code to append the tables to the file, thus saving the changes:
databaseCatalog.Tables.Append(appointmentsTable)
databaseCatalog.Tables.Append(patientsTable)
databaseCatalog.Tables.Append(xraysTable)
I am sure that these objectives I can achieve. However, in order to actually save the file, the user must indicate that they wish to do so, and here comes the tricky part. I wish to call the function that calls the aforementioned if statement, so that I can run the code to save the file. However, I need to pass a catalog into the function which is:
databaseCatalog.Create("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & fileDirectory & fileName)
And my button cannot use fileDirectory or fileName as these variables are not defined within it. As a result, my button cannot pass the appropriate catalog that will allow me to append my tables; if I try to use an empty catalog I get an error that states 'Object is no longer valid'. Is there anything I can do to pass the variable that contains the catalog into the button? Or a way around this? Thanks.
Continue reading...