VB.net Data Access Layer (DAL) class (SQL Server)-VBForums
Results 1 to 1 of 1

Thread: VB.net Data Access Layer (DAL) class (SQL Server)

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2004
    Location
    Sao Paulo / Brazil
    Posts
    33

    VB.net Data Access Layer (DAL) class (SQL Server)

    Here is a little DAL class i´ve made and use in all my projects.
    I hope it helps someone....

    It can call procedures and direct sql statements.
    You must feed the parameters before calling the proc/sql

    Attached file has a complete app with examples.

    Usage:

    Code:
        Private Sub btnProcedure_Click(sender As System.Object, e As System.EventArgs) Handles btnProcedure.Click
    
            Dim bdados As DAL
            Dim dsx As DataSet
    
            Try
    
                bdados = New DAL(GetConfig("Server"),
                                 GetConfig("Database"),
                                 GetConfig("User"),
                                 GetConfig("Password"))
    
    
                bdados.ClearParameters()
                bdados.AddParameters("OPERACAO", "GRID", DbType.String, 4)
                bdados.AddParameters("cEscriCobr", DBNull.Value, DbType.Decimal, 3)
                bdados.AddParameters("cSglEscriCobr", DBNull.Value, DbType.String, 2)
                bdados.AddParameters("iEscriCobr", DBNull.Value, DbType.String, 50)
                bdados.AddParameters("cdIndcdPrmssEnvioLote", DBNull.Value, DbType.Decimal, 1)
                bdados.AddParameters("rCmnhoArqPrestCta", DBNull.Value, DbType.String, 255)
                bdados.AddParameters("cIndcdEscriAtivo", DBNull.Value, DbType.Decimal, 1)
                bdados.AddParameters("cEnvioEscriCobr", DBNull.Value, DbType.String, 10)
    
                dsx = bdados.GetProcedure("pEscriCobr")
    
                If Not dsx Is Nothing Then
                    dgResult.DataSource = dsx.Tables(0)
                    dsx.Dispose()
                Else
                    MsgBox("Error: " & bdados.GetErrorDescription())
                End If
    
                bdados.Dispose()
    
            Catch ex As Exception
                MsgBox("Erro in Form1::btnSQL_Click: " & ex.ToString())
            Finally
                bdados = Nothing
                dsx = Nothing
            End Try
    
        End Sub
    Attached Files Attached Files
    Last edited by cbuosi; May 10th, 2012 at 08:59 PM.
    --------------------------------------
    All your base are belong to us.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.