이 VB 코드를 기반으로 모든 SQL 데이터베이스 내에서 올바르게 만들 수 있지만 Food_ID가 txtfoodid에 표시되는 대신 메시지 상자에 표시됩니다 (Try/Catch 때문이라고 생각합니다.)).텍스트 상자가 올바르게 표시되지 않음
Dim con As New OleDbConnection(DBcon)
Try
Dim dr As OleDbDataReader
Dim command As New OleDbCommand("Insert into Donation (Donor_ID) VALUES (" & txtDonNum.Text & "); Select @@Identity;")
con.Open()
command.Connection = con
dr = command.ExecuteReader
Dim Donation_ID As String = ""
If dr.Read() Then
Donation_ID = dr(0).ToString
Dim food As New OleDbCommand("Insert into Food_Donation (Date_Received, Donation_ID) Values ('" & maskedreceived.Text & "', " & Donation_ID & "); Select @@Identity")
food.Connection = con
dr = food.ExecuteReader()
'food.ExecuteNonQuery()
End If
Dim Food_ID As String
If dr.Read() Then
Food_ID = dr(0).ToString
txtfoodid.Text = dr("Food_ID").ToString
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
con.Close()
End Try
MessageBox.Show("Food_ID has been made.")
End Sub
여러 가지 방법으로 표시하려고했지만 지금까지 아무 것도 작동하지 않았습니다.