Updating a table

  • Thread starter Thread starter gwboolean
  • Start date Start date
G

gwboolean

Guest
I have been trying every way I can think of, and many of the ways got very weird, to replace a table value with a different value. This table consists of a single column, single row that holds a part number (the column is vchar). All I want to do is open the connection, retrieve the value (already got that part done), then later replace that value with an updated value (this is where the problem occurs).

Anyway, I have opened the connection, filled the table and tried various methods of replacing the value in the table, all of which failed. Can anyone tell me what I should be doing to make this work?

Below is one of the many, many, many methods I have tried to get this to work. Everything appears to work, but the column value is NOT updated.

Public Function IncrementFileMasterID(ByVal IncrementID As String) As Object
Dim strFileID As String = Nothing
'Increment ID number and Save to the FileMaster ID table
strFileID = CStr(_strFileMasterID)
Dim intFileID As Integer = CInt(Mid(strFileID, 3, 9))
intFileID += 1
strFileID = "FM" + CStr(intFileID)
'Open Connection and establish Command object
FileIDConn.MasterBaseOpen()
Dim FileIDTable As DataTable = New DataTable
FileIDCommand = New SqlCommand("Select chrFileMasterID From setFileMasterID", FileIDConn.MasterBaseConnection)
FileIDAdapter = New SqlDataAdapter()
FileIDAdapter.SelectCommand = FileIDCommand
Dim FileIDBuild As SqlCommandBuilder = New SqlCommandBuilder(FileIDAdapter)
FileIDAdapter.Fill(FileIDTable)
FileIDBindingSource.DataSource = FileIDTable
Dim FileIDDataRow As DataRow = FileIDTable.NewRow()
FileIDDataRow("") = CStr(strFileID)
FileIDTable.Rows.Add(FileIDDataRow)
FileIDAdapter.Update(FileIDTable)
FileIDConn.MasterBaseClose()
Return IncrementID
End Function




gwboolean

Continue reading...
 
Back
Top