1 Attachment(s)
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