0 Replies - 2087 Views - Last Post: 13 September 2009 - 12:58 AM Rate Topic: -----

#1 aieenaein  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 10-February 09

Trying to use ListView Control in VB6 for displaying table from a .mdb

Posted 13 September 2009 - 12:58 AM

Im having problems with the code that i've copied w/ my VB6 Class~
this is the code that i revised from what i've copied, i replaced the Table fields with the fields that are present in my MSAccess file,

Public Sub StudInfo()
	
	LV1.ListItems.Clear
	Set RS1 = New ADODB.Recordset
	
	SQL1 = "Select * from Student_Information"
	RS1.Open SQL1, Con, adOpenStatic, adLockOptimistic
	
	For N = 1 To RS1.RecordCount
		LV1.ListItems.Add , , RS1![StudentNumber]
		LV1.ListItems(LV1.ListItems.Count).ListSubItems.Add , , RS1!FamilyName
		LV1.ListItems(LV1.ListItems.Count).ListSubItems.Add , , RS1!FirstName
		LV1.ListItems(LV1.ListItems.Count).ListSubItems.Add , , RS1!MaternalName
		LV1.ListItems(LV1.ListItems.Count).ListSubItems.Add , , RS1!Birthdate
		LV1.ListItems(LV1.ListItems.Count).ListSubItems.Add , , RS1!Age
		LV1.ListItems(LV1.ListItems.Count).ListSubItems.Add , , RS1!FatherN
		LV1.ListItems(LV1.ListItems.Count).ListSubItems.Add , , RS1!MotherN
		LV1.ListItems(LV1.ListItems.Count).ListSubItems.Add , , RS1!FatherO
		LV1.ListItems(LV1.ListItems.Count).ListSubItems.Add , , RS1!MotherO
		LV1.ListItems(LV1.ListItems.Count).ListSubItems.Add , , RS1!Address
		LV1.ListItems(LV1.ListItems.Count).ListSubItems.Add , , RS1!Department
		LV1.ListItems(LV1.ListItems.Count).ListSubItems.Add , , RS1!Level
		LV1.ListItems(LV1.ListItems.Count).ListSubItems.Add , , RS1!SY
		LV1.ListItems(LV1.ListItems.Count).ListSubItems.Add , , RS1!TelNo
		LV1.ListItems(LV1.ListItems.Count).ListSubItems.Add , , RS1!ClassSched
		
		RS1.MoveNext
	Next N
	
	RS1.Close
	Set RS1 = Nothing
	
End Sub



it seems to have a problem with this line

 RS1.Open SQL1, Con, adOpenStatic, adLockOptimistic 


so i thought i must make a module that will have this ff. codes..
cuz at first i realized those are not yet declared so...

Public Con As ADODB.Connection
Public RS1 As ADODB.Recordset
Public Sub Main()
Set Con = New ADODB.Connection
	
	With Con
		.Provider = "Microsoft.Jet.OLEDB.4.0"
					App.Path "\Database\StudentsInfo.mdb;"
		.Open
	End With
	
	Set SQL1 = New ADODB.Command

End Sub


i thought it'll already solve the problem but it still doesn't work. i know i have limited knowledge in database, that's why i might make stupid mistakes here (which i really don't have any clue)

i think my main problem is 'How can i show MS Access File (table) using ListView Control' cuz i thought the first code will already do the trick...

sorry for being inactive in this forum for a long time... and then showing up just because i have a problem >__<
(that's why im really hesitating on posting this~)

Is This A Good Question/Topic? 0
  • +

Page 1 of 1