|
|
การรันรหัส เช่น S00001 vb.net แล้วรันได้แค่ S00009 แล้ว error แก้ยังไงคับ รบกวนทีคับ |
|
|
|
|
|
|
|
Code (VB.NET)
Public Function a1() As String
Dim id1 As String
Dim l1 As String
Dim dt1 As DataTable = New DataTable
Dim SQL1 As String
SQL1 = "SELECT Max(song_id) FROM song"
dt1 = c.ExRead(SQL1)
id1 = dt1(0)(0).ToString
If dt1(0)(0).ToString <> "" Then
If id1.Substring(id1.Length - 1) <> "9" Then
id1 = dt1(0)(0).ToString
l1 = id1.Substring(id1.Length - 1, id1.Length - 6)
id1 = id1.Substring(0, id1.Length - 1) + (Integer.Parse(l1) + 1).ToString
ElseIf dt1(0)(0).ToString.Substring(id1.Length - 1) = "9" Then
If dt1(0)(0).ToString.Substring(id1.Length - 2, id1.Length - 6) = "9" Then
If dt1(0)(0).ToString.Substring(id1.Length - 3, id1.Length - 6) = "9" Then
If dt1(0)(0).ToString.Substring(id1.Length - 4, id1.Length - 6) = "9" Then
If dt1(0)(0).ToString.Substring(id1.Length - 5, id1.Length - 6) = "9" Then
id1 = dt1(0)(0).ToString
l1 = Integer.Parse(id1.Substring(1, id1.Length - 6)) + 1
id1 = "S" + l1 + "00000"
Else
id1 = dt1(0)(0).ToString
l1 = Integer.Parse(id1.Substring(2, id1.Length - 6)) + 1
id1 = "S0" + l1 + "0000"
End If
Else
id1 = dt1(0)(0).ToString
l1 = Integer.Parse(id1.Substring(3, id1.Length - 6)) + 1
id1 = "S00" + l1 + "000"
End If
Else
id1 = dt1(0)(0).ToString
l1 = Integer.Parse(id1.Substring(4, id1.Length - 6)) + 1
id1 = "S000" + l1 + "00"
End If
Else
id1 = dt1(0)(0).ToString
l1 = Integer.Parse(id1.Substring(5, id1.Length - 6)) + 1
id1 = "S0000" + l1.ToString + "0"
End If
End If
ElseIf dt1(0)(0).ToString = "" Then
id1 = "S00001"
End If
Return id1
End Function
Tag : VB.NET
|
|
|
|
|
|
Date :
2010-10-15 03:39:10 |
By :
WALLE |
View :
1162 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
น่าจะมีวิธีที่ง่ายกว่านี้ครับ เขียนซะเยอะเลยครับ
|
|
|
|
|
Date :
2010-10-15 06:17:45 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เขียนยังไงหรอคับ รบกวนช่วยเขียนให้ดูทีคับ มือใหม่อยู่อ่ะคับ
|
|
|
|
|
Date :
2010-10-19 13:26:11 |
By :
WALLE |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|