Hello,
I've written the following code to add a new record to a database:
Code:
Public Shared Sub AddTopicUser(ByVal UserID As Integer, ByVal TopicCode As String)
Dim RowsAffected As Integer
Dim ATUDCONN As New OleDbConnection
ATUDCONN.ConnectionString = DBCONNSTR
Dim ATUDCMD As New OleDbCommand("INSERT INTO tblSubscriptions (UserID, TopicCode, Completed) Values (@UserID, @TopicCode, @Completed)", ATUDCONN)
Dim Completed As String = "No"
With ATUDCMD.Parameters
.AddWithValue("@UserID", UserID)
.AddWithValue("@TopicCode", TopicCode)
.AddWithValue("@Completed", Completed)
End With
Try
ATUDCONN.Open()
RowsAffected = ATUDCMD.ExecuteNonQuery()
ATUDCONN.Close()
ATUDCONN.Dispose()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
I recieve no errors from the code, but when i open the database after - the record has not been added.
I have checked that the values being passed as parameters to the function are valid. I was curious as to whether I was formatting the OleDbCmd correctly, but the value of RowsAffected is 1 at runtime which means that it's communicating with the database.
Any ideas when they're not being added to the db?
Ty.