我有三个关系表,这是我想做的。
我收到此错误:列名LastInsertID
无效 Private Sub cmdSave_Click(sender As Object, e As EventArgs) Handles cmdSave.Click
cn.Open()
Using cmd As New SqlClient.SqlCommand("INSERT INTO ParentInformation(father_firstname,father_lastname,father_mi,father_occupation " _
& " father_telnum,mother_firstName,mother_lastname,mother_mi,mother_occupation,mother_telnum," _
& " contact_firstname, contact_lastname,contact_MI, contact_Address, contact_telnum) " _
& " VALUES('" & txtFatherGN.Text & "', '" & txtFatherLN.Text & "','" & txtFatherMI.Text & "'," _
& " '" & txtFatherOccupation.Text & "','" & txtFatherCP.Text & "','" & txtMotherGN.Text & "' ," _
& " '" & txtMotherLN.Text & "','" & txtMotherMI.Text & "','" & txtMotherOccupation.Text & "'," _
& "'" & txtMotherCP.Text & "','" & txtContactGN.Text & "','" & txtContactLN.Text & "'," _
& "'" & txtContactMI.Text & "', '" & txtContactAddress.Text & "','" & txtContactCP.Text & "'; dim lastInsertedID as string = SELECT LAST_INSERT_ID())", cn)
End Using
Using cmd As New SqlClient.SqlCommand("INSERT INTO studentInformation(Surname,firstName, " _
& " MiddleName,Address,Birthday,Gender,Nationality,Birthplace, " _
& " Telnum,SchoolLastAttended,Note,Image,ParentID) " _
& " VALUES('" & txtStudLN.Text & "', '" & txtStudFN.Text & "','" & txtStudMN.Text & "'," _
& " '" & txtAddress.Text & "','" & dtpBirthday.Text & "','" & newStudent & "' ," _
& " '" & cboNationality.Text & "','" & txtPlaceOfBirth.Text & "','" & txtStudentCP.Text & "'," _
& "'" & cboSchoolYear.Text & "','" & cboGradeLevel.Text & "','" & txtSWG.Text & "'," _
& "'" & txtSchoolAddress.Text & "', '" & txtNote.Text & "',@StudentPic,lastInsertedID;dim lastInsertedID as string = SELECT LAST_INSERT_ID())", cn)
End Using
Using cmd As New SqlClient.SqlCommand("INSERT INTO StudentHistory(SchoolYear,Levels,Section,DateEnrolled ,StudentID) " _
& " VALUES('" & cboSchoolYear.Text & "','" & cboGradeLevel.Text & "', " _
& "'" & cboSection.Text & "','" & dtpEnrollment.Text & "', lastInsertedID)", cn)
cmd.Parameters.Add(New SqlClient.SqlParameter("@StudentPic", SqlDbType.Image)).Value = IO.File.ReadAllBytes(a.FileName)
i = cmd.ExecuteNonQuery
If (i > 0) Then
MsgBox("Save " & i & "Record Successfully")
'clear()
End If
End Using
cn.Close()
End Sub
任何人都可以帮我解决这个问题。提前谢谢
答案 0 :(得分:0)
尝试替换
,LAST_INSERT_ID()
与
_this.http.post(...).map is not a function
数据库服务器将了解LAST_INSERT_ID()
的最后一个值