Private Sub SaveNewShipLog()
Dim LibInfoAdp As OleDbDataAdapter 'For Library Information Table access
Dim LibProjAdp As OleDbDataAdapter 'For Project Table access
Dim ShipLogAdp As OleDbDataAdapter 'For Ship Log Table access
Dim ShipLstAdp As OleDbDataAdapter 'For Ship Log List Table access
Dim adoBldr As OleDbCommandBuilder
Dim adoDs As DataSet
Try
'Setup the adapters
LibInfoAdp = New OleDbDataAdapter(Me.BulidShippingLogSQL("library information"), adoCnn)
LibProjAdp = New OleDbDataAdapter(Me.BulidShippingLogSQL("lib_proj_tbl"), adoCnn)
ShipLogAdp = New OleDbDataAdapter(Me.BulidShippingLogSQL("ship_log_tbl"), adoCnn)
ShipLstAdp = New OleDbDataAdapter(Me.BulidShippingLogSQL("shp_log_lstn_tbl"), adoCnn)
'Make sure the adapters that the primary key.
LibInfoAdp.MissingSchemaAction = MissingSchemaAction.AddWithKey
LibProjAdp.MissingSchemaAction = MissingSchemaAction.AddWithKey
ShipLogAdp.MissingSchemaAction = MissingSchemaAction.AddWithKey
ShipLstAdp.MissingSchemaAction = MissingSchemaAction.AddWithKey
'Fill the dataset.
adoDs = New DataSet
LibInfoAdp.Fill(adoDs, "[Library Information]")
LibProjAdp.Fill(adoDs, "lib_proj_tbl")
ShipLogAdp.Fill(adoDs, "ship_log_tbl")
ShipLstAdp.Fill(adoDs, "shp_log_lstn_tbl")
'Test for library information change
Me.LibraryInfoUpdateTest(LibInfoAdp, adoDs)
'Dim dRow As DataRow = adoDs.Tables("ship_log_tbl").NewRow()
'dRow("PROJ_ID") = lngPROJ_ID
'dRow("LIB_TYPE_ID") = 1
'dRow("SHP_MTH_ID") = 1
'dRow("NSO_ID") = 1
'dRow("ship_date") = Today
'dRow("attetion_of") = "tester"
'dRow("cd_cs_person") = "tester2"
'dRow("lst_pricing") = True
'adoDs.Tables("ship_log_tbl").Rows.Add(dRow)
'adoBldr = New OleDbCommandBuilder(ShipLogAdp)
'ShipLogAdp.Update(adoDs, "ship_log_tbl")
'adoBldr.Dispose()
'adoBldr = Nothing
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Function LibraryInfoUpdateTest(ByRef adp As OleDbDataAdapter, ByVal ds As DataSet) As Boolean
Dim dRow As DataRow = ds.Tables("[Library Information]").Rows(0)
Dim bld As New OleDbCommandBuilder(adp)
Debug.Write(dRow("State"))
dRow("State") = "PA"
Debug.Write(dRow("State"))
dRow.AcceptChanges()
adp.Update(ds, "[Library Information]")
bld.Dispose()
bld = Nothing
End Function
Private Function BulidShippingLogSQL(ByVal DB_Table_Name As String) As String
Select Case DB_Table_Name.ToLower
Case "library information"
Return "SELECT " & _
"[Library Information].ID, " & _
"[Library Information].[Library Name], " & _
"[Library Information].Address1, " & _
"[Library Information].Address2, " & _
"[Library Information].City, " & _
"[Library Information].State, " & _
"[Library Information].Zip, " & _
"[Library Information].[Library Type] " & _
"FROM " & _
"[Library Information] " & _
"WHERE " & _
"[Library Information].ID = " & lngLIB_ID
Case "lib_proj_tbl"
Return "SELECT * " & _
"FROM " & _
"lib_proj_tbl " & _
"WHERE " & _
"PROJ_ID = " & lngPROJ_ID & " AND LIB_ID = " & lngLIB_ID
Case "ship_log_tbl"
Return "SELECT * FROM ship_log_tbl"
Case "shp_log_lstn_tbl"
Return "SELECT * FROM shp_log_lstn_tbl"
Case Else
End Select
End Function