Results 1 to 4 of 4

Thread: Updating a few fields within an MS ACCESS table.

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2008
    Posts
    5

    Question Updating a few fields within an MS ACCESS table.

    Hi everyone!

    I am trying to update a few fields with data. In an MS ACCESS db.

    I'm sure I have the syntax of the UPDATE command wrong. Can someone PLEASE tell me what I am doing wrong?
    Here's the code.
    Code:
     Public Sub SaveDB()
            ' This Function Saves the config into the database
            Dim databaseName As String = Application.StartupPath & "\CONFIG.DAT"
    
            Dim ServerName, NetID As String
            ServerName = frmConfig.txtServerName.Text
            NetID = frmConfig.txtNetID.Text
            Dim constring As String = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source =" & databaseName
            Using myconnection As New OleDbConnection(constring)
                myconnection.Open()
                Dim sqlQry As String = "UPDATE SystemData SET ServerName = '" & frmConfig.txtServerName.Text & "', ServerID = '" & frmConfig.txtNetID.Text & '" & WHERE configid=1;'"
    
               Using cmd As New OleDbCommand(sqlQry, myconnection)
                    cmd.Parameters.AddWithValue("@ServerName", ServerName)
                    cmd.Parameters.AddWithValue("@NetID", NetID)
                    cmd.ExecuteNonQuery()
                End Using
            End Using
    End Sub
    Last edited by WisconsinMan; Sep 6th, 2014 at 08:29 PM.

Tags for this Thread

Posting Permissions

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



Click Here to Expand Forum to Full Width