智能排课系统vb代码(13)
时间:2025-04-05
时间:2025-04-05
和智能智能排课系统1、2、3是一套
的连接
SqlString = "Select 课程名称,教师姓名,上课教室,班级编号,上课时间 from 排课表 " '形成查询字符串1
mandText = SqlString '设置Command对象执行的命令字符串
mandType = adCmdText '设置命令类型,表示CommandText中为一命令文本 ,童P188
Set RS1 = Cmd.Execute '执行命令得到一个结果记录集
Call ShowData(RS1, MSFlexGrid1) '调用过程显示记录集中的数据
End Sub
Private Sub Form_Load()
constr = "Driver={SQL Server};Server=PC2012110412ewr.;Database=GXPK;" _
& "uid =sa;pwd=t123" 'SQL Server普通安全模式建立到Pubs数据库的连接的连接字符串 '定义数据库连接
With Conn
.ConnectionString = constr '给ConnectionString属性赋值
.ConnectionTimeout = 10
.Open '给连接的ConnectionString属性赋值,然后使用求带参数的Open方法打开连接 End With
MsgBox ("连接成功")
End Sub
Private Sub Command1_Click() '调整教室
Dim rt As New ADODB.Recordset
If (Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Or Text4.Text = "" Or Text5.Text = "") Then
MsgBox ("请输入完整信息")
Else
Set Rs = New ADODB.Recordset
SQL = "select * from 排课表"
Set Rs = Conn.Execute(SQL)
If Rs("上课教室") = Text4.Text Then
MsgBox ("该时间段该教室已被占用,请重新选择")
Text4.Text = ""
Text5.Text = ""
Else
Set Rs = New ADODB.Recordset
SQL = "update 排课表 set [上课教室]='" + Text4.Text + "' where [课程名称]='" + Text1.Text + "' and [教师姓名]='" + Text2.Text + "' and [上课时间]='" + Text5.Text + "'"
Set Rs = Conn.Execute(SQL)
MsgBox ("教室调整成功")
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
上一篇:现代高血压药物治疗策略与趋势