dcsimg
Results 1 to 12 of 12

Thread: Deployment of a simple program with database for standalone use

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2019
    Posts
    8

    Deployment of a simple program with database for standalone use

    Hello!
    My Objective:
    I have to make a simple program that receives input from the user, calculates certain required parameters using a pre-defined database and returns the result. I have to distribute this program across many computers and I would like the program and the database to be standalone i.e. (1) minimum requirement of other third-party software and (2) No need for the database across all computers to be dynamically linked. Also, I would want to make the database as hidden as possible from the user.

    What I have already tried:
    I used VS2019 to create my forms and connected to my database in SQL server 2014 (managed using Management Studio 18) using connection string:
    Code:
    Server=localhost\SQLEXPRESS;Database=master;Trusted_Connection=True;
    The program works fine on my computer (I even added setup package for deployment and installed on my own computer to check) but doesn't work on other computers as expected (I haven't even figured out how to attach the database file along with the deployment or how to update the connection string for other computers). I have also read that just attaching the database file (not saying I know how to do that) wouldn't be enough and each computer would need SQL server installed.


    My Question:
    What database system (Access, SQL server, my SQL, etc.) should I use to make the job the most hassle-free considering my limited requirement in regard to working with the database ? Could you please also provide me with relevant examples with required connection strings, syntax, etc.?

  2. #2
    Junior Member
    Join Date
    Jul 2019
    Posts
    18

    Re: Deployment of a simple program with database for standalone use

    You can use one computer as server and then connect the rest remotely to access the database. This way you will only install the sql server on the server machine and install your software exe on all the machine

  3. #3
    Junior Member
    Join Date
    Jul 2019
    Posts
    18

    Re: Deployment of a simple program with database for standalone use

    I will recommend some tutorials

  4. #4

    Thread Starter
    New Member
    Join Date
    Jul 2019
    Posts
    8

    Re: Deployment of a simple program with database for standalone use

    Thank you for your reply. However, I want to distribute my program to various users without connecting them to a server or any network and working even without internet or any network connection for that matter. So, my question is how do I "add" my database for such "standalone" use? There seems to be a method to just add the mdf file in the visual studio project, how do I go about doing that?

  5. #5
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    4,170

    Re: Deployment of a simple program with database for standalone use

    SQLite would work well for your situation. All you have to do is copy the SQLite Dll's into the same folder as the app and your good to go. If you put the database in the same folder as your app then the connection string could be like, "Data Source = |DataDirectory|\yourdb.db;Version=3"

  6. #6
    Junior Member
    Join Date
    Jul 2019
    Posts
    18

    Re: Deployment of a simple program with database for standalone use

    Quote Originally Posted by Swop_K View Post
    Thank you for your reply. However, I want to distribute my program to various users without connecting them to a server or any network and working even without internet or any network connection for that matter. So, my question is how do I "add" my database for such "standalone" use? There seems to be a method to just add the mdf file in the visual studio project, how do I go about doing that?
    Oh okay, then you can use MS access or SQLite

  7. #7
    Fanatic Member
    Join Date
    Aug 2004
    Location
    Essex, UK
    Posts
    600

    Re: Deployment of a simple program with database for standalone use

    My vote goes to SQLite too. You can use SQLiteStudio to set up your tables. The database itself is just one file (usually with a .db3 extension) and then there are a couple of dll's you need to include in the app folder (as Wes said). In my small project the SQLite database is much smaller than the equivalent data stored in an Access mdb.

  8. #8
    Frenzied Member
    Join Date
    Dec 2014
    Location
    VB6 dinosaur land
    Posts
    1,169

    Re: Deployment of a simple program with database for standalone use

    Quote Originally Posted by Swop_K View Post
    Also, I would want to make the database as hidden as possible from the user.
    Elaborate on what you mean by "hidden". Presumably you don't want them to change the data? Or you don't want them to even see it? The data should be encrypted?

  9. #9

    Thread Starter
    New Member
    Join Date
    Jul 2019
    Posts
    8

    Re: Deployment of a simple program with database for standalone use

    Thanks a lot. Could you please direct me to any sample projects, codes or tutorials on working with SQlite in VB.net?

  10. #10
    Fanatic Member
    Join Date
    Aug 2004
    Location
    Essex, UK
    Posts
    600

    Re: Deployment of a simple program with database for standalone use

    This is how I connect a DataGridView to a table:

    Code:
    Imports System.Data.SQLite
    
        Private Sub Connect_DGV()
    
            Dim myConn As New SQLiteConnection("Data Source=c:\mydatabase.db3;version=3")
            myConn.Open()
    
            Dim cmd As New SQLiteCommand
            cmd.Connection = myConn
    
            Dim sql As String = "Select LogID,strftime('%d/%m/%Y',DateTimeStart),strftime('%H%M',DateTimeStart),Callsign,Fband,
                                Frequency,Mode,Sent,Recv,Locator,Postcode,OpName,Notes,Valid,MyCall,MyLoc,DateTimeEnd
                                 from tblLog order by DateTimeStart"
    
            cmd.CommandText = sql
    
            Dim rdr As Data.SQLite.SQLiteDataReader = cmd.ExecuteReader
            Dim dt As New DataTable
            dt.Load(rdr)
    
            rdr.Close()
            myConn.Close()
    
            dgvLog.DataSource = dt
    
        End Sub

  11. #11
    Fanatic Member
    Join Date
    Aug 2004
    Location
    Essex, UK
    Posts
    600

    Re: Deployment of a simple program with database for standalone use

    Update a table using parameters (use the same import as previous post)
    Code:
            Using connection As New SQLiteConnection("Data Source=c:\mydatabase.db3;version=3")
    
                Dim cmd As String = "UPDATE tblLog SET (DateTimeStart,Callsign,Fband,Frequency,Mode,Sent,Recv,
                                     Locator,Postcode,OpName,Notes,Valid,MyCall,MyLoc,DateTimeEnd)
                                    =(@DateTimeStart,@Callsign,@Fband,@Frequency,@Mode,@Sent,@Recv,@Locator,
                                     @Postcode,@OpName,@Notes,@Valid,@MyCall,@MyLoc,@DateTimeEnd)
                                     WHERE LogId='" & GiQSOid & "'"
    
                Using comm As New SQLiteCommand(cmd, connection)
    
                    comm.Parameters.AddWithValue("@DateTimeStart", txtDateTimeStart.Text)
                    comm.Parameters.AddWithValue("@Callsign", txtCallsign.Text)
                    comm.Parameters.AddWithValue("@Fband", txtFband.Text)
                    comm.Parameters.AddWithValue("@Frequency", txtFrequency.Text)
                    comm.Parameters.AddWithValue("@Mode", txtMode.Text)
                    comm.Parameters.AddWithValue("@Sent", txtSent.Text)
                    comm.Parameters.AddWithValue("@Recv", txtRecv.Text)
                    comm.Parameters.AddWithValue("@Locator", txtLocator.Text)
                    comm.Parameters.AddWithValue("@Postcode", txtPostcode.Text)
                    comm.Parameters.AddWithValue("@OpName", txtOpName.Text)
                    comm.Parameters.AddWithValue("@Notes", txtNotes.Text)
                    comm.Parameters.AddWithValue("@Valid", chkValid.Checked)
                    comm.Parameters.AddWithValue("@MyCall", txtMyCall.Text)
                    comm.Parameters.AddWithValue("@MyLoc", txtMyLoc.Text)
                    comm.Parameters.AddWithValue("@DateTimeEnd", txtDateTimeEnd.Text)
    
                    connection.Open()
                    comm.ExecuteNonQuery()
    
                End Using
    
            End Using

  12. #12
    Fanatic Member
    Join Date
    Aug 2004
    Location
    Essex, UK
    Posts
    600

    Re: Deployment of a simple program with database for standalone use

    Populate some textboxes from one record. The ID of the record is given in GiQSOid (as it was in the previous post).
    Code:
            Using myConn As New SQLiteConnection(GsConString)
    
                myConn.Open()
    
                Dim cmd As New SQLiteCommand With {
                    .Connection = myConn,
                    .CommandText = "SELECT * FROM tblLog WHERE LogID='" & GiQSOid & "'"
                }
    
                Using reader As SQLiteDataReader = cmd.ExecuteReader()
                    If reader.HasRows Then
                        reader.Read()
                        txtDateTimeStart.Text = reader.Item("DateTimeStart").ToString
                        txtDateTimeEnd.Text = reader.Item("DateTimeEnd").ToString
                        txtCallsign.Text = reader.Item("Callsign").ToString
                        txtFband.Text = reader.Item("Fband").ToString
                        txtFrequency.Text = reader.Item("Frequency").ToString
                        txtMode.Text = reader.Item("Mode").ToString
                        txtSent.Text = reader.Item("Sent").ToString
                        txtRecv.Text = reader.Item("Recv").ToString
                        txtLocator.Text = reader.Item("Locator").ToString
                        txtPostcode.Text = reader.Item("Postcode").ToString
                        txtOpName.Text = reader.Item("OpName").ToString
                        txtNotes.Text = reader.Item("Notes").ToString
                        txtMyCall.Text = reader.Item("MyCall").ToString
                        txtMyLoc.Text = reader.Item("MyLoc").ToString
                        chkValid.Checked = CBool(reader.Item("Valid"))
                    End If
                End Using
    
            End Using
    Last edited by paulg4ije; Sep 1st, 2019 at 05:29 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width