hi guys
can i ask... i have a treeview here connceted to retrieve my 5 tables in mysql 3.51 to update the record but when the records is being retrieved all the records in the database even the other contents that are not needed is being retrieved. Pls help me with this guys i have a thesis work in next week and i was stuck in here for 4 week.... I am open in any replies!
Thanks in advans!
Public Sub S_SET_TREE_VIEW()
Dim sqlMain As String
Dim rsMain As New ADODB.Recordset
Dim sql1 As String
Dim rs1 As New ADODB.Recordset
If BudOperation = "NEW" Then
sqlMain = "Select count(detBUdcode) as NoRec from detmain_tab where detbudcode='" & lblBudgetCode.Text & "' And" & _
" recStat='" & "TEMP" & "'"
ElseIf BudOperation = "ADJUST" Then
sqlMain = "Select count(detBUdcode) as NoRec from detmain_tab where detbudcode='" & lblBudgetCode.Text & "' And" & _
" recStat='" & "SAVE" & "'"
End If
m = 0
rsMain.Open(sqlMain, conn)
If rsMain.EOF = False Then
main = rsMain.Fields(0).Value
rsMain.Close()
Else
rsMain.Close()
Exit Sub
End If
If BudOperation = "NEW" Then
sqlMain = "Select m_partDesc from detmain_tab where detBudCode ='" & lblBudgetCode.Text & "' And" & _
" recStat='" & "TEMP" & "'"
ElseIf BudOperation = "ADJUST" Then
sqlMain = "Select m_partDesc from detmain_tab where detbudcode ='" & lblBudgetCode.Text & "' And" & _
" recStat='" & "SAVE" & "'"
End If
rsMain.Open(sqlMain, conn)
Do While m < main
Dim tvTN As New TreeNode
tvTN.Text = rsMain.Fields(0).Value
tvBudgetDet.Nodes(0).Nodes.Add(tvTN)
S_SET_NODE_SUBMAIN(tvTN.Text)
m = m + 1
rsMain.MoveNext()
Loop
rsMain.Close()
End Sub
Public Sub S_SET_NODE_SUBMAIN(ByVal MainDesc As String)
Dim sqlSubMain As String
Dim rsSubMain As New ADODB.Recordset
ms = 0
If BudOperation = "NEW" Then
sqlSubMain = "Select count(ms.ms_partDesc) as NoRec from detMain_tab as m, detSubMain_tab as ms where m.detMaincode = ms.detMaincode and m.m_partDesc ='" & MainDesc & "' And" & _
" ms.recStat='" & "TEMP" & "'"
ElseIf BudOperation = "ADJUST" Then
End If
rsSubMain.Open(sqlSubMain, conn)
If rsSubMain.EOF = False Then
submain = rsSubMain.Fields(0).Value
rsSubMain.Close()
Else
rsSubMain.Close()
Exit Sub
End If
If BudOperation = "NEW" Then
sqlSubMain = "Select ms.ms_partDesc from detMain_tab as m, detSubMain_tab as ms where m.detMaincode = ms.detMaincode and m.m_partDesc ='" & MainDesc & "' And" & _
" ms.recStat='" & "TEMP" & "'"
ElseIf BudOperation = "ADJUST" Then
End If
rsSubMain.Open(sqlSubMain, conn)
If rsSubMain.EOF = False Then
Do While ms < submain
Dim tvN As New TreeNode
tvN.Text = rsSubMain.Fields(0).Value
tvBudgetDet.Nodes(0).Nodes(tmp).Nodes.Add(tvN)
S_SET_NODE_CAT(tvN.Text)
ms = ms + 1
rsSubMain.MoveNext()
Loop
End If
tmp = tmp + 1
End Sub
Public Sub S_SET_NODE_CAT(ByVal submainDesc As String)
Dim sqlCat As String
Dim rsCat As New ADODB.Recordset
c = 0
If BudOperation = "NEW" Then
sqlCat = "Select count(dc.detCatCode) as NoRec" & _
" from detSubMain_tab as dm, detCat_tab as dc" & _
" where dm.detSubMainCode = dc.detSubMainCode and" & _
" dm.ms_partDesc ='" & submainDesc & "' And dc.recStat='" & "TEMP" & "'"
ElseIf BudOperation = "ADJUST" Then
End If
rsCat.Open(sqlCat, conn)
If rsCat.EOF = False Then
cat = rsCat.Fields(0).Value
rsCat.Close()
Else
rsCat.Close()
Exit Sub
End If
If BudOperation = "NEW" Then
sqlCat = "Select dc.c_partDesc" & _
" from detSubMain_tab as dm, detCat_tab as dc" & _
" where dm.detSubMainCode = dc.detSubMainCode and" & _
" dm.ms_partDesc ='" & submainDesc & "' And dc.recStat='" & "TEMP" & "'"
ElseIf BudOperation = "ADJUST" Then
End If
rsCat.Open(sqlCat, conn)
If rsCat.EOF = False Then
Do While c < cat
Dim tvN As New TreeNode
tvN.Text = rsCat.Fields(0).Value
tvBudgetDet.Nodes(0).Nodes(m).Nodes(ms).Nodes.Add(tvN)
S_SET_NODE_SUBCAT(tvN.Text)
c = c + 1
rsCat.MoveNext()
Loop
End If
tmpC = tmpC + 1
End Sub
Public Sub S_SET_NODE_SUBCAT(ByVal catDesc As String)
Dim sqlSubCat As String
Dim rsSubCat As New ADODB.Recordset
cs = 0
If BudOperation = "NEW" Then
sqlSubCat = "Select count(dcs.detSubCatCode) as NoRec" & _
" from detSubCat_tab as dcs, detCat_tab as dc" & _
" where dcs.detCatCode = dc.detCatcode and" & _
" dc.c_partDesc ='" & catDesc & "' And dcs.recStat ='" & "TEMP" & "'"
ElseIf BudOperation = "ADJUST" Then
End If
rsSubCat.Open(sqlSubCat, conn)
If rsSubCat.EOF = False Then
subcat = rsSubCat.Fields(0).Value
rsSubCat.Close()
Else
rsSubCat.Close()
Exit Sub
End If
If BudOperation = "NEW" Then
sqlSubCat = "Select dcs.cs_partDesc as NoRec" & _
" from detSubCat_tab as dcs, detCat_tab as dc" & _
" where dcs.detCatCode = dc.detCatcode and" & _
" dc.c_partDesc ='" & catDesc & "' And dcs.recStat ='" & "TEMP" & "'"
ElseIf BudOperation = "ADJUST" Then
End If
rsSubCat.Open(sqlSubCat, conn)
If rsSubCat.EOF = False Then
Do While cs < subcat
Dim tvN As New TreeNode
tvN.Text = rsSubCat.Fields(0).Value
tvBudgetDet.Nodes(0).Nodes(m).Nodes(ms).Nodes(c).Nodes.Add(tvN)
cs = cs + 1
rsSubCat.MoveNext()
Loop
End If
tmpcs = tmpcs + 1
End Sub