iT邦幫忙

0

vb.net問題(判斷欄位日期編號+1)

  • 分享至 

  • xImage

請問各位高手
小弟需要判斷欄位是否有值
如果有值編號就自動+1上去
但最後到10就會停住
上不去了
請各位高手幫忙提點一下問題出在哪裡,謝謝大家。


    Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load


        Dim dt As DataTable = New DataTable()
        Dim text As String = ""
        Using CONN1 As SqlConnection = New SqlConnection()
            CONN1.ConnectionString = ""
            Dim sql1 As String
            sql1 = "(SELECT Convert(varchar(6),Getdate(),112)+ isnull( replicate('0',( 2-len(  convert(varchar(24),(MAX(RIGHT([D0101],2))+1))) )) + convert(char(2),(MAX(RIGHT([D0101],2))+1)),'01') from [QA8D01] where left([D0101],6) = '" & DateTime.Now.ToString("yyyyMM") & "')"
            Dim adapter As SqlDataAdapter = New SqlDataAdapter(sql1, CONN1)
            adapter.Fill(dt)
            If dt.Rows.Count = 1 Then
                text = dt.Rows(0)(0).ToString()
            End If
        

        End Using


        ID1.Text = text


    End Sub
pinglam iT邦新手 5 級 ‧ 2020-05-19 17:04:59 檢舉
可否提供Data template?
z22344566 iT邦新手 4 級 ‧ 2020-05-19 17:19:47 檢舉
請問是這個嗎 ?
https://dbfiddle.uk/?rdbms=sqlserver_2017&fiddle=a71b06d30e3672f5a88da6239660e77a
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友回答

立即登入回答