我正在使用 Vb6 !我有一个名为“Datagrid1”的数据网格,我从访问数据库的 Datagrid1 中名为“subjectcode”的表中显示某些内容,例如主题名、主题代码、理论实用。
我还有另一个名为“feedetail”的表。我的疑问是,如果“theory_practical”值是理论值,那么它应该显示名为 feedetail 的表中的理论费,或者如果“theroy_practical”值是实际值,那么它应该在名为“Fee”的新列中显示实际费用数据网格1。
我对 sql 语句和在 datagrid 中显示感到困惑!这是我使用的代码!
我想在 Theory_Practical 标题的下一栏中显示相应的费用!我无法附加屏幕截图文件,它显示错误!所以这里是截图文件的链接!提前致谢 !
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
费用表:
Heading(Year1,Year2,Theoryfee,Practicalfee)
values (2001,2003,440,320)
像这样的所有其他值只有不同的值!
主题代码表:
Heading(Year1,Year2,Subjectcode,Subjectname,Theory_Practical)
values (2001,2003,RCCS10CS1,C programming, Theory)