Link to home
Start Free TrialLog in
Avatar of MBHEY131
MBHEY131

asked on

oledb database updates on joined queries

here's my code:
       Dim oledbDA As System.Data.OleDb.OleDbDataAdapter
        Dim oleFillComm As System.Data.OleDb.OleDbCommand
        Dim oleUpdComm As System.Data.OleDb.OleDbCommand

        Dim oleDS As DataSet

        oleFillComm = New System.Data.OleDb.OleDbCommand
        oleUpdComm = New System.Data.OleDb.OleDbCommand
        oleDS = New DataSet

        oleconn = New System.Data.OleDb.OleDbConnection
        oledbDA = New System.Data.OleDb.OleDbDataAdapter
        oleconn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
            "Data Source=C:\ShopHand\ShopHand\ShopHand\slspro.mdb;" & _
            "Persist Security Info=True"
        oleconn.Open()

        oleFillComm.Connection = oleconn

        oleFillComm.CommandText = "SELECT        Stock.VIN, Customers.LastName, Customers.FirstName, Customers.MiddleInitial, Customers.Address1, Customers.Address2, Customers.City, " & _
        "Customers.State, Customers.Zip, Customers.EmailAddress, Customers.CellPhone, Customers.HomePhone, Customers.WorkPhone, Customers.Fax, Customers.County, " & _
        "Stock.StockNum, Stock.Make, Stock.Model, Stock.ModelCode, Stock.[Memo], Stock.Body, Stock.Color, Stock.Engine, Stock.MilesIn, Stock.ExistingPlate, Stock.DeliveryDate, " & _
        "Customers.Do_Not_Call, Customers.IsBusiness, Customers.IsCurrent, Customers.BaseAddressID, Customers.ActiveDate, Customers.SocialSecurity, Customers.CountyCode, Customers.DateOfBirth, Customers.DriversLicense, " & _
        "Customers.DriversLicenseState, Customers.LastWriteCount, Customers.DriversLicenseExpiration, Stock.InventoryID, Stock.AdjustedCost, Stock.AdjustedMsrp, Stock.Adv, Customers.IsEmployee, Customers.Notes, Customers.PayrollDeduction, " & _
        "Stock.AppendTimeStamp, Stock.BookValue, Stock.BrokerAmount, Stock.BrokerID, Stock.Buyer,Stock.ColorCode, Stock.Cost, Stock.DMVType, Stock.EquipmentOptions, " & _
        "Stock.Freight, Stock.HoldBack, Stock.Ignition, Stock.IgnitionLocation, Stock.InvoiceDate, Stock.InvoiceNumber, Stock.Location, Stock.MileageType,  Stock.MilesOut, " & _
        "Stock.MSRP, Stock.NewVehicle, Stock.Pack, Stock.PictureFilename, Stock.PurchasedFrom, Stock.SellingPrice, Stock.SoldToBrokerAmount, Stock.SoldToBrokerID, Stock.StockDate, " & _
        "Stock.TitleNumber, Stock.TitleType, Stock.TradeACV, Stock.TradeAddToStock, Stock.TradeAllowance, Stock.TradeBookValue, Stock.TradeLien, Stock.Transmission, Stock.Trunk, " & _
        "Stock.TrunkLocation, Stock.WebPrice, Stock.Weight, Stock.[Year], Stock.VehicleStatus, Stock.IsOnFloorPlan, Stock.WasDemo, Stock.ExistingPlateExpires, " & _
        "Stock.FloorPlanCompanyOID, Stock.FloorPlanCompanyName, Stock.FloorPlanRate, Stock.FloorPlanGrace, Stock.FlooredAmount, Stock.IncludeFloorPlanInAdjCost, Stock.FloorPlanEndDate, Stock.FloorPlanAccum, " & _
        "Stock.InspectionStationNumber, Stock.WebDescription1, Stock.WebDescription2, Stock.WebDescription3, Stock.WebDescription4, Stock.WebDescription5, Stock.WebDescription6, Stock.WasWholesale, " & _
        "Stock.FormattedStockNum, Stock.IsRepo, Stock.NumCylinders, Stock.NumDoors, Stock.FuelType, Stock.InteriorColor, Stock.InteriorType, Stock.IsCertified, Stock.AutoRevoEquipment, " & _
        "Stock.AutoTraderEquipment, Stock.IsSpecial, Stock.SpecialExpires, Stock.SpecialPrice, Stock.SeatingCapacity, Stock.LastWriteCount AS Expr1, Stock.VehicleNotes, Stock.DataFeeds_DoNotSend, Stock.VideoURL, " & _
        "Stock.SegmentationCode, Stock.QRCode, Stock.TitleOrigin, Stock.VIN + ' ' + Customers.LastName + ',  ' + Customers.FirstName + ' ' + Customers.MiddleInitial AS VINDisplay, " & _
        "Customers.LastName + ',  ' + Customers.FirstName + ' ' + Customers.MiddleInitial + ' ' + Stock.VIN AS LastNameDisplay, Deals.DealID, Deals.ApprovalNumber, Deals.Buyer AS Expr2, Deals.CoBuyer, " & _
        "Deals.CoSigner, Deals.CustomerSource, Deals.DealDate, Deals.DealNumber, Deals.DealStatus, Deals.DealType, Deals.DeliveredDate, Deals.FinanceInfo, Deals.FinancingType, Deals.InsuranceCompany, " & _
        "Deals.InsurancePolicyNum, Deals.IsDelivered, Deals.LenderApprovalNumber, Deals.LenderID, Deals.ManagerID, Deals.Misc, Deals.PayrollDeductID, Deals.PlateExpireDate, Deals.PlateLevelWt, " & _
        "Deals.PlateMonth, Deals.PlateNumber, Deals.PlateType, Deals.PolicyNumber, Deals.SalesmanID, Deals.TaxExemptID, Deals.Trade1, Deals.Trade2, Deals.VehicleSold, Deals.TempReg, Deals.Trade1Leinholder, " & _
        "Deals.Trade2Leinholder, Deals.BuyerCurrentAddress, Deals.InsuranceEffectiveFrom, Deals.InsuranceEffectiveTo, Deals.CreditApp, Deals.CreditAppGUID, Deals.DrivewayAppID, Deals.DrivewaySubmissionDate, " & _
        "Deals.LocalLenderAppID, Deals.FundingStatus, Deals.FundingDate, Deals.LastWriteCount AS Expr3, Deals.LicensePlateCode, Customers.CustomerID " & _
"FROM            ((Customers INNER JOIN " & _
                         "Stock ON Customers.CustomerID = Stock.PurchasedFrom) INNER JOIN " & _
                         "Deals ON Stock.InventoryID = Deals.VehicleSold) " & _
"ORDER BY Customers.LastName"

        oledbDA.SelectCommand = oleFillComm
        oledbDA.Fill(oleDS)

        Me.DataGridView1.DataSource = oleDS.Tables(0)


        oleconn.Close()

Open in new window


I'm loading the DATAGRIDVIEW and everything is fine with sorts, etc
my problem is when I want to update the TABLES in the database

Can anyone HELP with the update command?
Avatar of JHMH IT Staff
JHMH IT Staff
Flag of United States of America image

What are you updating; are you adding new records or updating existing records?
Avatar of MBHEY131
MBHEY131

ASKER

Expert Comment

JHMH IT Staff2015-06-04 at 04:06:54ID: 40812261




What are you updating; are you adding new records or updating existing records?
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
BOTH
===================================================================
HERE'S my connection string:

       oleconn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
            "Data Source=C:\ShopHand\ShopHand\ShopHand\slspro.mdb;" & _
            "Persist Security Info=True"
        oleconn.Open()
it appears I'm going to have to write the update text commands manually but how?
ASKER CERTIFIED SOLUTION
Avatar of JHMH IT Staff
JHMH IT Staff
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
that's what I was afraid you were going to tell me:

Here's my plan - I am not going to change any code to this point - it just works too well and is exactly what everyone want's - My problem is on the update to the databases and I will make 3 defferent data adapters and datasets and copy each row (and column) to the appropriate dataset - which is what I think you were getting at in your post above
and then update with the update command!
thanx
loop through the datagrid1 I mean
Yep, once you move away from the "built in" datagridview components you have to do a lot of manual labor to program in the other queries such as inserts and updates. Good luck!
Expert Comment
JHMH IT Staff2015-06-04 at 06:18:57ID: 40812551
Yep, once you move away from the "built in" datagridview components you have to do a lot of manual labor to program in the other queries such as inserts and updates. Good luck!
+++++++++++++++++++++++++
this database is not mine as I am tying into another's data for integration purposes and I have very little room to maneuver here - so it's not really by choice but by customer and economic necessity!!
======================================
No, I meant the built in database functions in Visual Studio. When you add a DataGridView you can manually program it or attach a dataset through Visual Studio's database wizard.
yes I know what you meant and although a novice programmer and just getting up to date on databases but I do have many datagrids that attach to "MY" database and yes the updates are defiantly easier but this data is oledb as opposed to sql and I really need the query to get more than 1 table in that dataset.