ทำโปรเจอร้านเช่าหนัง VB2010 ต่อ SQL server 2008 ค่ะ มือใหม่เพิ่งเริ่มได้ครึ่งเดือนค่ะ
Code (VBScript)
Dim drTmp As SqlDataReader
Dim sqlTmp As String
If txtname.Text = "" Then
sqlTmp = "SELECT pd_no from Product order by pd_no DESC"
With da
.SelectCommand = New SqlCommand(sqlTmp, sqlcon)
.Fill(ds, "pd_no")
End With
Dim sql As New SqlCommand
With sql
.CommandType = CommandType.Text
.CommandText = sqlTmp
.Connection = sqlcon
drTmp = .ExecuteReader
End With
If drTmp.HasRows Then
drTmp.Read()
Dim i As Integer = 0
Dim strTmp As String
strTmp = drTmp(0)
i = strTmp.Substring(1)
i += 1
txtno.Text = "C" & i.ToString("00000")
Else
txtno.Text = "C" & "00001"
End If
Tag : .NET, Ms SQL Server 2008, VB.NET, VS 2010 (.NET 4.x)