0
請檢查並糾正這種代碼要生成併爲每個條目
Public Function RegisterToEventFAMLY(ByVal p As Participant, ByVal PartcName As String, ByVal Rel As String, ByVal DOB As String, ByVal EVT As String) As String
Using con As New SqlConnection(CONNECTION_STRING)
Dim cmdEv As New SqlCommand("select 'TATA' + RIGHT('0000'+CAST(CHESTNO+1 as VARCHAR(4)),4) from (select top 1 CHESTNO=CAST(RIGHT(CHESTNO,4)as int) from [SANDBOX].[dbo].[T_HTK_USR_DTLS] order by CHESTNO desc) t where [email protected]", con)
cmdEv.Parameters.AddWithValue("IDNo", p.ID)
Dim daEv As New SqlDataAdapter(cmdEv)
Dim dtEv As New DataTable
Try
Dim newRowCreated = False
daEv.Fill(dtEv)
Dim drEv As DataRow
If (dtEv.Rows.Count > 0) Then
drEv = dtEv.Rows(0)
Else
drEv = dtEv.NewRow
newRowCreated = True
End If
drEv("Pno") = p.ID
drEv("NAME") = PartcName ''---event code
drEv("BASE_LOCATION") = DOB
drEv("EVENTNM") = Rel
drEv("MAC_ID") = Rel
If (newRowCreated) Then
dtEv.Rows.Add(drEv)
End If
Dim cmdbEv As New SqlCommandBuilder(daEv)
cmdbEv.ConflictOption = ConflictOption.OverwriteChanges
daEv.Update(dtEv)
Catch ex As Exception
Return ex.Message
End Try
End Using
Return "True"
End Function
顯示異常錯誤
無效列名 'PNO' 返回唯一ID
您是否已將列放入您的'SELECT'語句中?我知道它在其他地方,但爲了使用它,您需要將它帶入「SELECT」部分,以便它可以訪問。 'SELECT Pno,column2,column3 etc from ...' – Bugs
@GurV你是對的。你能否糾正我的問題 – Rab