Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Problem with populating datagrid

Problem with populating datagrid

Scheduled Pinned Locked Moved ASP.NET
helpdatabasedebuggingworkspace
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    i
    wrote on last edited by
    #1

    i dont know why tis application wont works... it keep giving me the first records in the database and populate it twice, when i wanted both 2 different records to appear... if possible help me debug this or give me some comments... thanks in advance... Dim aryTest(2) as integer arytest(0) = 1 arytest(1) = 2 Dim objAdapter As New SqlDataAdapter Dim objDs As New DataSet Dim ojDataRow As DataRow Dim objArrayList As New ArrayList objCMDB = New cCMDB Dim i As Integer For i = 0 To 1 mobjcmd.CommandText = "SELECT Contract_Ref,Equipment_Status, " & _ "Technology_Refresh_Eligibility, Configuration_Item_Description, " & _ "Configuration_Type, Maintenance_Contract, Procurement_Vendor, " & _ "Warrenty_Ends, Warrenty_Period FROM tblCMDB WHERE" & _ "Configuration_Item_ID = "& aryTest(i) & "" mobjcmd.SelectCommand = mobjcmd objAdaptor.Fill(objDs, "tblcCMDBRecords") objDataRow = objDs.Tables("tblcCMDBRecords").Rows(0) objcCMDB.ContractReference = objDataRow.Item("Contract_Ref") objcCMDB.EquipmentStatus = objDataRow.Item("Equipment_Status") objcCMDB.TechnologyRefreshEligibility = objDataRow.Item ("Technology_Refresh_Eligibility") objcCMDB.ConfigurationItemDescription = objDataRow.Item ("Configuration_Item_Description") objcCMDB.ConfigurationType = objDataRow.Item("Configuration_Type") objcCMDB.MaintenanceContract = objDataRow.Item("Maintenance_Contract") objcCMDB.ProcurementVendor = objDataRow.Item("Procurement_Vendor") objcCMDB.WarrentyEnds = objDataRow.Item("Warrenty_Ends") objcCMDB.WarrentyPeriod = objDataRow.Item("Warrenty_Period") objArrayList.Add(objcCMDB) Next MobjCn.Close() Return objArrayList i@@

    M 1 Reply Last reply
    0
    • I i

      i dont know why tis application wont works... it keep giving me the first records in the database and populate it twice, when i wanted both 2 different records to appear... if possible help me debug this or give me some comments... thanks in advance... Dim aryTest(2) as integer arytest(0) = 1 arytest(1) = 2 Dim objAdapter As New SqlDataAdapter Dim objDs As New DataSet Dim ojDataRow As DataRow Dim objArrayList As New ArrayList objCMDB = New cCMDB Dim i As Integer For i = 0 To 1 mobjcmd.CommandText = "SELECT Contract_Ref,Equipment_Status, " & _ "Technology_Refresh_Eligibility, Configuration_Item_Description, " & _ "Configuration_Type, Maintenance_Contract, Procurement_Vendor, " & _ "Warrenty_Ends, Warrenty_Period FROM tblCMDB WHERE" & _ "Configuration_Item_ID = "& aryTest(i) & "" mobjcmd.SelectCommand = mobjcmd objAdaptor.Fill(objDs, "tblcCMDBRecords") objDataRow = objDs.Tables("tblcCMDBRecords").Rows(0) objcCMDB.ContractReference = objDataRow.Item("Contract_Ref") objcCMDB.EquipmentStatus = objDataRow.Item("Equipment_Status") objcCMDB.TechnologyRefreshEligibility = objDataRow.Item ("Technology_Refresh_Eligibility") objcCMDB.ConfigurationItemDescription = objDataRow.Item ("Configuration_Item_Description") objcCMDB.ConfigurationType = objDataRow.Item("Configuration_Type") objcCMDB.MaintenanceContract = objDataRow.Item("Maintenance_Contract") objcCMDB.ProcurementVendor = objDataRow.Item("Procurement_Vendor") objcCMDB.WarrentyEnds = objDataRow.Item("Warrenty_Ends") objcCMDB.WarrentyPeriod = objDataRow.Item("Warrenty_Period") objArrayList.Add(objcCMDB) Next MobjCn.Close() Return objArrayList i@@

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      You need to recreate the new objcCMDB object in the for loop statement, otherwise it will overrite the current object.

      I 1 Reply Last reply
      0
      • M minhpc_bk

        You need to recreate the new objcCMDB object in the for loop statement, otherwise it will overrite the current object.

        I Offline
        I Offline
        i
        wrote on last edited by
        #3

        thx dude thx for ur help... u save me...:cool::cool::cool:

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups