So I have a database (for tracking customer applications through to approval etc.) in MS Access form & and all (but access just isnt the best way to do this for many reasons I wont get into).

I have looked at lots of programming language and decide that VB was best since i am somewhat familiar with it (from VBA). I added a new data source and did a form but now i realized that this make a copy of my existing database and saved in the project folder. This is not what i wanted. I wanted it to connect to and use the existing on that I have on a server. I need ppl from different branches to access this be and thus cannot have it on my computer. I was wondering if after i have published this program will the file get information from the server or continue from this file? and if not (get from the server) how do I make it use only that file on the server. I have created a login form that i know connects to the server. Below is the code that I use for that form. Is there away to get the data source to only the one from the server or will i have to do something like below?

Imports System.Data.OleDb

Public Class CTSLoginForm

    ' OK button   
    Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
        Dim con As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\Atlanet\loantracking\CTS_be.mdb")
        Dim cmd As OleDbCommand = New OleDbCommand("SELECT * FROM MSysUserList WHERE Username = '" & usernametextbox.Text & "' AND Password = '" & passwordtextbox.Text & "' ", con)
        Dim sdr As OleDbDataReader = cmd.ExecuteReader()
        ' If the record can be queried, Pass verification and open another form.   
        If (sdr.Read() = True) Then
            MessageBox.Show("The user is valid!")
            Dim MainForm As New CreditTrackingSystemPARENT
            MessageBox.Show("Invalid username or password!")
        End If
    End Sub

    ' Cancel button   
    Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
    End Sub

End Class

In Visual Studio 20005/2008 you can add a new connection through a wizard.
At one point the wizard tells you that you've selected a local data file that's not in the current project, and asks if you would like to copy the database file to your project folder.

Choosing NO will keep the database file at the current location and your VB project will use and share that file.

Awesome! Thanks. I will try that. For now, what I had done was to go and edit the settings of the connection.


            Dim idnumber As String = TextBox1.Text
            Dim nname As String = TextBox2.Text
            Dim nadress As String = TextBox7.Text
            Dim nage As String = TextBox4.Text
            Dim nfemale As String = CheckBox1.Checked
            Dim ntype As String = ComboBox3.SelectedItem
            Dim nmobil As String = TextBox5.Text
            Dim ndate As String = DateTimePicker1.Checked
            Dim ndoctor As String = ComboBox4.SelectedItem
            Dim idnational As String = TextBox3.Text
            Dim sname As String = ComboBox2.SelectedItem

            Dim con As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Abu Qais\Documents\db1.mdb")
            Dim sql As String = "INSERT INTO Table1 VALUES(@1,@2,@3,@4,@5,@6,@7,@8,@9,@10.@11)"
            Dim sqlc As New OleDbCommand(sql, con)
            sqlc.Parameters.AddWithValue("@1", idnumber)
            sqlc.Parameters.AddWithValue("@2", Name)
            sqlc.Parameters.AddWithValue("@3", nadress)
            sqlc.Parameters.AddWithValue("@4", nage)
            sqlc.Parameters.AddWithValue("@5", nfemale)
            sqlc.Parameters.AddWithValue("@6", ntype)
            sqlc.Parameters.AddWithValue("@7", nmobil)
            sqlc.Parameters.AddWithValue("@8", ndate)
            sqlc.Parameters.AddWithValue("@9", ndoctor)
            sqlc.Parameters.AddWithValue("@10", idnational)
            sqlc.Parameters.AddWithValue("@11", sname)

            MsgBox("Data Save")
            TextBox1.Text = ""
            TextBox2.Text = ""
            TextBox3.Text = ""
            TextBox4.Text = ""
            TextBox5.Text = ""
            TextBox6.Text = ""
            TextBox7.Text = ""
            TextBox8.Text = ""
        Catch ex As Exception
            MsgBox("please Check The Data", MsgBoxStyle.OkOnly + MsgBoxStyle.Information, "Check")
        End Try
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.