Hi am trying to develop the web version of my desktop application using C# asp.net core, but am not sure of how to handle the databases, Here is what i want to achieve, my desktop application is a Point of sales system developed using VB whereby the application user are able to manage multiple stores and every store has it own database, upon the creation of the store the database script is executed which now create the database for the New store. Below is my sample code to create the database.
'Get DB NAme
Dim DbNumber As Integer
ConnectTools()
cmd.CommandText = "select MAX(StoreCount) as cntt from tblStores"
rd = cmd.ExecuteReader
rd.Read()
If IsDBNull(rd.Item("cntt")) Then
DbNumber = "1"
Else
DbNumber = rd.Item("cntt") + 1
End If
rd.Close()
DatabaseName = "AutemStore" & DbNumber
cmd.Connection = conn
'conn.Open()
conn.ChangeDatabase("Master")
If conn.State = ConnectionState.Open Then conn.Close()
conn.Open()
cmd.CommandText = "Create Database " & DatabaseName
cmd.ExecuteNonQuery()
'Save DB Name
My.Settings.DatabaseName = DatabaseName
My.Settings.Save()
'Run DB Script
conn.ChangeDatabase(My.Settings.DatabaseName)
cmd.CommandText = ReadFile(Application.StartupPath & "\dstore.sql")
cmd.CommandType = CommandType.Text
cmd.ExecuteNonQuery()
I believe there is a way this task i just explained can be done using Asp.net core but I don't yet have a clue on how to get it done, please is there any suggestion on how to do this or alternative way to get it done. Thanks in advance.