I'm transitioning a old app from an ACCESS DB to a SQL Server Express DB. Have been trying to update several columns in an access table. I can retrieve data from the table so I know my connection is correct but I cannot write to it. Here is one example of the code I've tried:
Calling Method -
' Add required parameters.
SQL.AddParam("anonymous user", userID)
SQL.AddParam("@pw", "%" & PwordTxtBx2.Text & "%")
' Build query string & execute query.
SQL.ExecQuery("UPDATE Profiles " &
"SET Password=@pw " &
"WHERE UserID=anonymous user;")
' Was the update successful?
Select Case SQL.HasException(T)
Execution Method -
Try
' Open a connection to the database.
DbCon.Open()
' Create DB Command
DbCmd = New SqlCommand(query, DbCon)
'Load Params into DB Command
Params.ForEach(Sub(p) DbCmd.Parameters.Add(p))
' Clear Params List
Params.Clear()
' Execute Command & Fill Dataset
DbDt = New DataTable
DbDa = New SqlDataAdapter(DbCmd)
RecCnt = DbDa.Fill(DbDt)
Catch ex As SqlException
' Capture thrown error & create an error message.
ExErr = $"SQL Error: {ex.Message}"
UserMsg(3, "Update Failure!" & dblLf & ExErr)
Finally
' Close Connection
If DbCon.State = ConnectionState.Open Then DbCon.Close()
End Try
DB was built in VS 2019 an placed in the working directory of the project. Any suggestion would be greatly appreciated.