I am using Vb6 ! I have one datagrid named "Datagrid1" and i display certain contents such as subjectname, subjectcode, theory_practical from the table named "subjectcode" in Datagrid1 from access database. And i have another table named "feedetail". My doubt is, if the "theory_practical" value is theory means, then it should display the theoryfee from the table named feedetail or if "theroy_practical" value is practical means, then it should display practical fee in the new column named "Fee" in datagrid1.... i am having confusion with the sql statement and displaying in datagrid ! here is my code that i used !
Public con As New ADODB.Connection Public rs As New ADODB.Recordset Public rs2 As New ADODB.Recordset Private Sub Command1_Click() Dim semesternew As String semesternew = semester.Caption Select Case semesternew Case "I" semester1 = 1 Case "II" semester1 = 2 Case "III" semester1 = 3 Case "IV" semester1 = 4 Case "V" semester1 = 5 Case "VI" semester1 = 6 End Select DataGrid1.ClearFields rs.Open "select Subjectcode,Subjectname,Theory_Practical from subjectcode as s where s.Degree='" & Degree & "' and s.Branch='" & course & "' and s.Year1='" & year1 & "' and s.Year2='" & year2 & "' and s.Semester='" & semester1 & "' ", con, 1, 3 Set DataGrid1.DataSource = rs End Sub Private Sub Command2_Click() examfee2.Hide examfee1.Show End Sub Private Sub Command4_Click() If rs!Theory_Practical = "theory" Then rs2.Open "select Theoryfee from Degreelevel", con, 1, 3 Set DataGrid2.DataSource = rs2 ElseIf rs!Theory_Practical = "practical" Then rs2.Open "select Practicalfee from Degreelevel", con, 1, 3 Set DataGrid2.DataSource = rs2 End If End Sub Private Sub Form_Load() Set con = New ADODB.Connection con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=.\college.mdb;Persist Security Info=False" con.CursorLocation = adUseClient Set rs = New ADODB.Recordset End Sub
I want to display the corresponding fee in the next column to the Theory_Practical heading ! I can't attach a screenshot file n it shows error ! so here is the link of the screenshot file ! http://tinypic.com/r/2gwtdaq/6 Thanks in advance !