我正在使用以下存储过程来调用期间编号以将它们与教师匹配。
我们正在编写一个考勤应用程序,从下拉菜单中选择教师的姓名后,“句号”下拉菜单就会出现。出于某种原因,我们没有得到要填充的周期数据。
存储过程:
ALTER PROCEDURE spGetPeriod @Period varchar(10)
AS
SELECT Period
FROM tmTeacher
WHERE Period = @Period
RETURN
Teacher Table
TeacherId varchar(10) Unchecked
FName varchar(20) Checked
LName varchar(20) Checked
StudentId varchar(10) Unchecked
Period varchar(10) Unchecked
TeacherName varchar(50) Checked
Period Table
PeriodId varchar(10) Unchecked
Period varchar(50) Unchecked
ClassId varchar(10) Unchecked
提前致谢!
调用 SP 的代码:
'***** SETUP THE CONNECTION ***
SQL = "spGetPeriod '" + (cboTeacher.Text) + "'"
'SQL = "select * from teacher"
Try
With SqlCmd
.CommandText = SQL
'.CommandType = CommandType.StoredProcedure
.Connection = objConnection
'.Parameters.AddWithValue("@TeacherId", cboTeacher.SelectedIndex)
End With
SqlCmd = New SqlCommand(SQL, objConnection)
Catch ex As Exception
Call ErrorControl(ex)
End Try
'*** MAKE THE CONNECTION ***
Try
HandleConnection(objConnection)
'MsgBox("Connection Established!")
ToolStripStatusLabel1.Text = "Connection Established!"
Catch ex As Exception
Call ErrorControl(ex)
End Try
'*** EXECUTE THE COMMAND AND FILL THE COMBO ***
Dim Reader As SqlDataReader = SqlCmd.ExecuteReader()
While Reader.Read()
cboPeriod.Items.Add(Reader(0).ToString)
End While
ToolStripStatusLabel1.Text = "Periods Loaded!"
End Sub