主题:数据库编程
帮帮忙啊!!! 谢谢!!
为什么他老是提示这个:
实时错误 '-2147217900 (80040e14)':
第一行:'.'附近有语法错误。
调试的时候,指向这一段代码:
.Open "select 教师信息.*,系名称 from 教师信息,系部信息" & _
"where 教师信息.系编号=系部信息.系编号"
如果把这一段屏蔽掉,就会指向类似的下一个open处的代码
代码:
Private Sub Form_Load()
Set objCn = New Connection
With objCn
.Provider = "sqloledb"
.ConnectionString = "user id =sa;pwd=uag260811;data source=zheng;" & "initial catalog=学籍管理"
.Open
End With
Set objTeacher = New Recordset
With objTeacher
Set .ActiveConnection = objCn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.Open "select 教师信息.*,系名称 from 教师信息,系部信息" & _
"where 教师信息.系编号=系部信息.系编号"
End With
Set objScore = New Recordset
With objScore
Set .ActiveConnection = objCn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockOptimistic
.Open "select 课编号,课程信息.名称 as 课程名称,学生 as 学生编号," & _
"成绩,姓名,系名称,班级信息.名称 as 班名称" & _
"from 选课记录,课程信息,学生信息,班级信息,系部信息" & _
"where 选课记录.课编号=课程信息.编号 and " & _
"选课记录.学生=学生信息.编号" & _
"and 学生信息.班编号=班级信息.编号 and " & _
"学生信息.系编号=系部信息.系编号 order by 学生编号"
If .RecordCount > 0 Then
.MoveFirst
Dim i%
While Not .EOF
For i = 0 To cmbNum.ListCount - 1
If .Fields("学生编号") = cmbNum.List(i) Then Exit For
Next
If i = cmbNum.ListCount Then cmbNum.AddItem ("学生编号")
.MoveNext
Wend
End If
.Filter = "学生编号='" & cmbNum & "'"
Set dgList.DataSource = objScore
dgList.Columns(2).Visible = False
dgList.Columns(4).Visible = False
dgList.Columns(5).Visible = False
dgList.Columns(6).Visible = False
End With
End Sub
为什么他老是提示这个:
实时错误 '-2147217900 (80040e14)':
第一行:'.'附近有语法错误。
调试的时候,指向这一段代码:
.Open "select 教师信息.*,系名称 from 教师信息,系部信息" & _
"where 教师信息.系编号=系部信息.系编号"
如果把这一段屏蔽掉,就会指向类似的下一个open处的代码
代码:
Private Sub Form_Load()
Set objCn = New Connection
With objCn
.Provider = "sqloledb"
.ConnectionString = "user id =sa;pwd=uag260811;data source=zheng;" & "initial catalog=学籍管理"
.Open
End With
Set objTeacher = New Recordset
With objTeacher
Set .ActiveConnection = objCn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.Open "select 教师信息.*,系名称 from 教师信息,系部信息" & _
"where 教师信息.系编号=系部信息.系编号"
End With
Set objScore = New Recordset
With objScore
Set .ActiveConnection = objCn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockOptimistic
.Open "select 课编号,课程信息.名称 as 课程名称,学生 as 学生编号," & _
"成绩,姓名,系名称,班级信息.名称 as 班名称" & _
"from 选课记录,课程信息,学生信息,班级信息,系部信息" & _
"where 选课记录.课编号=课程信息.编号 and " & _
"选课记录.学生=学生信息.编号" & _
"and 学生信息.班编号=班级信息.编号 and " & _
"学生信息.系编号=系部信息.系编号 order by 学生编号"
If .RecordCount > 0 Then
.MoveFirst
Dim i%
While Not .EOF
For i = 0 To cmbNum.ListCount - 1
If .Fields("学生编号") = cmbNum.List(i) Then Exit For
Next
If i = cmbNum.ListCount Then cmbNum.AddItem ("学生编号")
.MoveNext
Wend
End If
.Filter = "学生编号='" & cmbNum & "'"
Set dgList.DataSource = objScore
dgList.Columns(2).Visible = False
dgList.Columns(4).Visible = False
dgList.Columns(5).Visible = False
dgList.Columns(6).Visible = False
End With
End Sub