Dim Nowdate As DateTime
strsql = "SELECT MAX(date_check) AS MaxDate FROM View_GoodsCheck_Data GROUP BY re_id"
connectdb()
cm = New SqlCommand(strsql, cn)
rs = cm.ExecuteReader
If rs.Read Then
If rs.Item("MaxDate") Is Nothing Then
txt1.Text = lbldt.Text
Else
Nowdate = rs("MaxDate")
txt1.Text = Nowdate.Month & "/" & Nowdate.Day & "/" & Nowdate.Year & " 00:00:00"
End If
End If
closedb()
Tag : .NET, Ms SQL Server 2005, VS 2005 (.NET 2.x)
Date :
2015-06-18 11:29:56
By :
nameball
View :
754
Reply :
5
No. 1
Guest
Code (VB.NET)
'แทนที่บรรทัดที่ 2
'strsql = "SELECT MAX(date_check) AS MaxDate FROM View_GoodsCheck_Data GROUP BY re_id"
'ด้วยสิ่งนี้
Dim cmdBuilder As New System.Text.StringBuilder()
cmdBuilder.AppendLine("DECLARE @RETVAL AS DATE ;")
cmdBuilder.AppendLine()
cmdBuilder.AppendLine("IF EXISTS(SELECT 1 FROM [STUDENT])")
cmdBuilder.AppendLine(" SELECT @RETVAL = BIRTHDAY FROM [STUDENT]")
cmdBuilder.AppendLine("ELSE")
cmdBuilder.AppendLine(" SET @RETVAL = GETDATE() ;")
cmdBuilder.AppendLine()
cmdBuilder.AppendLine("SELECT @RETVAL ;")
strsql = cmdBuilder.ToString()
Date :
2015-06-18 17:37:32
By :
DOG{B}
No. 2
Guest
Code (VB.NET)
'เวรละลืมเปลี่ยน field อันนี้ๆ
'แทนที่บรรทัดที่ 2
'strsql = "SELECT MAX(date_check) AS MaxDate FROM View_GoodsCheck_Data GROUP BY re_id"
'ด้วยสิ่งนี้
Dim cmdBuilder As New System.Text.StringBuilder()
cmdBuilder.AppendLine("DECLARE @RETVAL AS DATE ;")
cmdBuilder.AppendLine()
cmdBuilder.AppendLine("IF EXISTS(SELECT 1 FROM [ View_GoodsCheck_Data])")
cmdBuilder.AppendLine(" SELECT @RETVAL=MAX(date_check) FROM View_GoodsCheck_Data GROUP BY re_id ;")
cmdBuilder.AppendLine("ELSE")
cmdBuilder.AppendLine(" SET @RETVAL = GETDATE() ;")
cmdBuilder.AppendLine()
cmdBuilder.AppendLine("SELECT @RETVAL ;")
strsql = cmdBuilder.ToString()
Date :
2015-06-18 17:40:44
By :
DOG{B}
No. 3
Guest
Code (VB.NET)
cmdBuilder.AppendLine("IF EXISTS(SELECT 1 FROM [View_GoodsCheck_Data])")
'ลบ space ออกด้วยครัชเดี๋ยวจะผิด