こんにちは、私は現在、ローカルの .mdf データベースでレッスンの詳細を調べようとしていますが、それができないようです。この問題が数週間続いており、本当に解決する必要があるので、何か助けがあれば教えてください。とても有難い。以下のフォームのコードを含めます。よろしくお願いします。
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim Session As String
Session = txtSession.text
Dim con As New SqlConnection
Dim inscmd As New SqlCommand
con.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("RoomBookingSystem.My.MySettings.Database1ConnectionString1").ConnectionString
Try
Using cn As New SqlConnection(con.ConnectionString)
con.Open()
Dim ParamInitial As New SqlParameter
ParamInitial.ParameterName = ("@StaffInitials")
ParamInitial.Value = lblStaffInitials.Text.Trim()
inscmd.Parameters.Add(ParamInitial)
Dim ParamWeek As New SqlParameter
ParamWeek.ParameterName = ("@Week")
ParamWeek.Value = lblWeek.Text.Trim
inscmd.Parameters.Add(ParamWeek)
Dim ParamPeriod As New SqlParameter
ParamPeriod.ParameterName = ("@Period")
ParamPeriod.Value = lblPeriod.Text.Trim
inscmd.Parameters.Add(ParamPeriod)
Dim ParamDay As New SqlParameter
ParamDay.ParameterName = ("@Day")
ParamDay.Value = lblDay.Text.Trim
inscmd.Parameters.Add(ParamDay)
Dim ParamSubject As New SqlParameter
ParamSubject.ParameterName = ("@Subject")
ParamSubject.Value = lblSubject.Text.Trim
inscmd.Parameters.Add(ParamSubject)
Dim ParamYearGroup As New SqlParameter
ParamYearGroup.ParameterName = ("@YearGroup")
ParamYearGroup.Value = lblYear.Text.Trim
inscmd.Parameters.Add(ParamYearGroup)
Dim ParamNumberPupils As New SqlParameter
ParamNumberPupils.ParameterName = ("@NumberOfPupils")
ParamNumberPupils.Value = lblNoOfPupils.Text.Trim
inscmd.Parameters.Add(ParamNumberPupils)
Dim ParamControlledAssesment As New SqlParameter
ParamControlledAssesment.ParameterName = ("@ControlledAssesment")
ParamControlledAssesment.Value = lblControlledAssesment.Text.Trim
inscmd.Parameters.Add(ParamControlledAssesment)
Dim ParamRoom As New SqlParameter
ParamRoom.ParameterName = ("@Room")
ParamRoom.Value = lblRoom.Text.Trim
inscmd.Parameters.Add(ParamRoom)
Dim ParamSession As New SqlParameter
ParamSession.ParameterName = ("@Session")
ParamSession.Value = txtSession.Text.Trim
inscmd.Parameters.Add(ParamSession)
inscmd.CommandText = "INSERT INTO Booking (Week, Day, Period, Subject, YearGroup, StaffInitials, NumberOfPupils, Session, Room, ControlledAssesment)VALUES (@Week,@Day,@Period,@Subject,@YearGroup,@StaffInitials,@NumberOfPupils,@Session,@Room,@ControlledAssesment)"
'inscmd.CommandText = "INSERT INTO Booking (Week, Day, Period, Subject, YearGroup, StaffInitials, NumberOfPupils, Session, Room, ControlledAssesment)VALUES ('B','Monday',5,'Politics','U6','JAGG',5,'5','LIT','False')"
Print(inscmd.CommandText)
inscmd.Connection = con
inscmd.ExecuteNonQuery()
con.Close()
inscmd.Parameters.Clear()
End Using
' Catch ex As Exception
' MsgBox("" & ex.Message)
'if there is an error it will go here (can use Msgbox or label)
Finally
con.Close()
End Try
MsgBox("Your Booking Has Been Made Successfully")
Clicky = False
MainViewForm.btnBackToBooking.Visible = False
FormView.Show()
Me.Hide()
con.Close()
End Sub