Below is my code connection to my database..I highlight with red color my target database. And I would like to ask, what is the safest way to target the database. Because Im thinking, what if my database is change to another directory. If that happens, it will cause trouble to my system. I hope someone can help me with this. Thanks in advance :)
Private Sub btnSaveExit_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSaveExit.Click
provider = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source ="
dataFile = "C:\Users\compUser\Documents\TestDB.accdb"
connString = provider & dataFile
myConnection.Open()
Dim str As String
str = "insert into tblEmployee ([Fname], [LName], [Position], [Division], [CostCenter], [Shift], [Workstation]) values (?, ?, ?, ?, ?, ?, ?)"
Dim cmd As OleDbCommand = New OleDbCommand(str, myConnection)
cmd.Parameters.Add(New OleDbParameter("FName", CType(txtFName.Text, String)))
cmd.Parameters.Add(New OleDbParameter("LName", CType(txtLName.Text, String)))
cmd.Parameters.Add(New OleDbParameter("Position", CType(txtPosition.Text, String)))
cmd.Parameters.Add(New OleDbParameter("Division", CType(txtDivision.Text, String)))
cmd.Parameters.Add(New OleDbParameter("CostCenter", CType(txtShift.Text, String)))
cmd.Parameters.Add(New OleDbParameter("Workstation", CType(txtWorkstation.Text, String)))
Try
cmd.ExecuteNonQuery()
Catch ex As Exception
txtFName.Clear()
txtLName.Clear()
txtPosition.Clear()
txtDivision.Clear()
txtCostCenter.Clear()
txtShift.Clear()
txtWorkstation.Clear()
End Try
End Sub