G
Guest
I'm trying to create a getFunction that returns a single value from an sql
table (the next sequence number actually in a group of records). I tried two
different methods, a command and data adaptor. Here is the code:
Private Function getNextSeq()
Dim strsql
Dim lds As DataSet = New DataSet()
strsql = "select max(cmt_seq_No) from oelincmt_sql where ord_No = '"
& gstrOrder & "'" _
& " line_seq_no = 0" & " Ord_type = '" & "O" & "'"
' the following 2 lines of code errored out:
Dim cmd As SqlCommand = New SqlCommand(strsql, sqlConn)
getNextSeq = cmd.ExecuteScalar
'then I tried this code which also errored out
Dim lda As SqlDataAdapter = New SqlDataAdapter(strsql, sqlConn)
lda.Fill(lds, "nextSeqNo")
getNextSeq = lds.Tables("nextSeq").Rows(0).Item(0)
end function
I would apreciate some advice as to the recommended way to create such a
function?
table (the next sequence number actually in a group of records). I tried two
different methods, a command and data adaptor. Here is the code:
Private Function getNextSeq()
Dim strsql
Dim lds As DataSet = New DataSet()
strsql = "select max(cmt_seq_No) from oelincmt_sql where ord_No = '"
& gstrOrder & "'" _
& " line_seq_no = 0" & " Ord_type = '" & "O" & "'"
' the following 2 lines of code errored out:
Dim cmd As SqlCommand = New SqlCommand(strsql, sqlConn)
getNextSeq = cmd.ExecuteScalar
'then I tried this code which also errored out
Dim lda As SqlDataAdapter = New SqlDataAdapter(strsql, sqlConn)
lda.Fill(lds, "nextSeqNo")
getNextSeq = lds.Tables("nextSeq").Rows(0).Item(0)
end function
I would apreciate some advice as to the recommended way to create such a
function?