Simple ADO.NET connection

Posted On // Leave a Comment
Public _ADOConnectionString As String = "provider=SQLOLEDB;Data Source=192.168.10.28" & _
                                ";Initial Catalog=ADMS3;Persist Security Info=True;User ID=sa;Password=creator;"

Public _
        _ADOConnection As New OleDb.OleDbConnection

Try
            _ADOConnection.ConnectionString = _ADOConnectionString
            _ADOConnection.Open()

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

Dim strSQL As String = "SELECT ISNULL(MAX(SUBSTRING(Nomor,9,8)),0) AS Nomor FROM uniMutasiGudang " & _
                               "WHERE SUBSTRING(Nomor,5,2) = '" & VB.Left(cboCabang.EditValue, 2) & "'"
        Dim OLEDBCommand As OleDbCommand = New OleDbCommand(strSQL, _ADOConnection)
        Dim __ADOReader As OleDbDataReader = OLEDBCommand.ExecuteReader



While __ADOReader.Read
            intNomor = CInt(__ADOReader("Nomor"))
        End While
        __ADOReader.Close()

0 komentar: