VB

Posting/Pertanyaan:

contoh membuat auto number


dim sConn as string
sConn = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=TabelKu;Data Source=."
Dim s As String
s = "SELECT MAX(LEFT(NOMOR," & m_lMaxDigit & ")) FROM tabelku"
lMax = CDbl(getReadOnlyRSSQL(s, sConn).Fields(0))
lCount = lMax + 1
Dim i As Integer
Dim lDigit As Long: lDigit = Len(CStr(lCount))
Dim sAutoTran As String
For i = 1 To (m_lMaxDigit - lDigit)
sAutoTran = sAutoTran & "0"
Next i
sAutoTran = sAutoTran & CStr(lCount)


Function getReadOnlyRSSQL(sSQL, Optional sConn As String) As ADODB.Recordset


Dim oConnTemp As New ADODB.Connection
Dim rsTemp As ADODB.Recordset
Set rsTemp = New ADODB.Recordset

oConnTemp.CursorLocation = adUseClient
oConnTemp.open sConn
rsTemp.open sSQL, oConnTemp, adOpenKeyset

If rsTemp.State = 1 Then
If rsTemp.RecordCount > 0 Then
Set getReadOnlyRSSQL = rsTemp
Else
Set getReadOnlyRSSQL = Nothing
End If
End If

Set oConnTemp = Nothing
Set rsTemp = Nothing
End Function

Tanggapan/Jawaban:

1. hartoto_d@yahoo.com
byk yang menanyakan ini jadi saya jawab di sini aja ya...
 




Kirim Jawaban/Komentar:  

Email  

Jawab  


© xbasicpro 2003 - 2010