Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. IT & Infrastructure
  4. i made the DB , now i need to build the application

i made the DB , now i need to build the application

Scheduled Pinned Locked Moved IT & Infrastructure
databasecsharphelptutorial
16 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Hasan Jaffal
    wrote on last edited by
    #1

    hi guys i need a help i made the database of a project but now i should start the application i'll use the vb.net as language so i need to know what are the steps implement the data access layer the data bussness layer then how to create instances and all other infos so plz help .. f anyone have an article a documentation... plz

    R C 2 Replies Last reply
    0
    • H Hasan Jaffal

      hi guys i need a help i made the database of a project but now i should start the application i'll use the vb.net as language so i need to know what are the steps implement the data access layer the data bussness layer then how to create instances and all other infos so plz help .. f anyone have an article a documentation... plz

      R Offline
      R Offline
      Rob Graham
      wrote on last edited by
      #2

      Some good stuff on generic data access here[^]

      H 2 Replies Last reply
      0
      • R Rob Graham

        Some good stuff on generic data access here[^]

        H Offline
        H Offline
        Hasan Jaffal
        wrote on last edited by
        #3

        thanks i'll try it but if anyone have more ...

        1 Reply Last reply
        0
        • R Rob Graham

          Some good stuff on generic data access here[^]

          H Offline
          H Offline
          Hasan Jaffal
          wrote on last edited by
          #4

          man that wasn't what i need sory man i want a tutorial to make the classes then to make the BLL then how to make objects to use in the windows application -interface thanks

          1 Reply Last reply
          0
          • H Hasan Jaffal

            hi guys i need a help i made the database of a project but now i should start the application i'll use the vb.net as language so i need to know what are the steps implement the data access layer the data bussness layer then how to create instances and all other infos so plz help .. f anyone have an article a documentation... plz

            C Offline
            C Offline
            Christian Graus
            wrote on last edited by
            #5

            You want to know how to write the entire application ? Do you know VB.NET at all ?

            Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

            H 1 Reply Last reply
            0
            • C Christian Graus

              You want to know how to write the entire application ? Do you know VB.NET at all ?

              Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

              H Offline
              H Offline
              Hasan Jaffal
              wrote on last edited by
              #6

              sure man i know vb.net and i wrote applications before but they weren't very good from the point of view seperation on layers and i read that i should seperate Data layer - sql : i know it very well data access layer bussniess logic layer presentation - vb.net : i know it very well so i need to know how to pass from data layer to DAL to BLL then in the application if i use classe for each table or something like that... how to make instances ... before i craete a dataset for each class and if i call the select methode of the classe, where i wrote the call of the stored procedure, i put the rows in this dataset ... so i feel that this isn't what they mean by DAL or BLL thanks

              C 1 Reply Last reply
              0
              • H Hasan Jaffal

                sure man i know vb.net and i wrote applications before but they weren't very good from the point of view seperation on layers and i read that i should seperate Data layer - sql : i know it very well data access layer bussniess logic layer presentation - vb.net : i know it very well so i need to know how to pass from data layer to DAL to BLL then in the application if i use classe for each table or something like that... how to make instances ... before i craete a dataset for each class and if i call the select methode of the classe, where i wrote the call of the stored procedure, i put the rows in this dataset ... so i feel that this isn't what they mean by DAL or BLL thanks

                C Offline
                C Offline
                Christian Graus
                wrote on last edited by
                #7

                OK, now we've narrowed down the question. The DAL should contain only code for accessing the database. It should expose methods that don't reveal anything about where the data comes from, such as List SearchForEntityObjects(string search). The business layer contains all the classes that create objects and enforce rules about how the app behaves. The Presentation layer should really only present UI and call business layer objects to do the behind the scenes work. If it us to do with UI, it belongs in the presentation layer. If it's to do with data access, it belongs in the DAL. The rest goes in the middle tier. Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

                H 1 Reply Last reply
                0
                • C Christian Graus

                  OK, now we've narrowed down the question. The DAL should contain only code for accessing the database. It should expose methods that don't reveal anything about where the data comes from, such as List SearchForEntityObjects(string search). The business layer contains all the classes that create objects and enforce rules about how the app behaves. The Presentation layer should really only present UI and call business layer objects to do the behind the scenes work. If it us to do with UI, it belongs in the presentation layer. If it's to do with data access, it belongs in the DAL. The rest goes in the middle tier. Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

                  H Offline
                  H Offline
                  Hasan Jaffal
                  wrote on last edited by
                  #8

                  ok man thanks for help so the question is ... how to make them ... i have 6-7 tables ... i know alittle UML ... so i can know the classes to made but in DAL i should create a class , who has attributes the feild of the table and who has methods like add,delete,update,... these methode calls stored procedures, on opening a connection, calling the procedure, putting the data in a data set, closing the connection, returning the dataset ??? that what i made before ... so is this right ? if that is right ... what's the BLL ... thanks 4 the help man

                  C 1 Reply Last reply
                  0
                  • H Hasan Jaffal

                    ok man thanks for help so the question is ... how to make them ... i have 6-7 tables ... i know alittle UML ... so i can know the classes to made but in DAL i should create a class , who has attributes the feild of the table and who has methods like add,delete,update,... these methode calls stored procedures, on opening a connection, calling the procedure, putting the data in a data set, closing the connection, returning the dataset ??? that what i made before ... so is this right ? if that is right ... what's the BLL ... thanks 4 the help man

                    C Offline
                    C Offline
                    Christian Graus
                    wrote on last edited by
                    #9

                    Lord Hasan wrote:

                    know alittle UML

                    You're ahead of me, I know none...

                    Lord Hasan wrote:

                    but in DAL i should create a class , who has attributes the feild of the table and who has methods like add,delete,update,...

                    I'd create a datalayer class for each object that calls it, so if you have a Person class, have a PersonDataLayer class. This class will return and accept Person objects, and each method exposed will map to a stored proc.

                    Lord Hasan wrote:

                    these methode calls stored procedures, on opening a connection, calling the procedure, putting the data in a data set, closing the connection, returning the dataset ??? that what i made before ... so is this right ?

                    You can return datasets, or you can return entity objects. Returning entity objects is prettier, but on complex systems, in the absence of friend classes, can make keeping things OO a little difficult. Either way will work fine.

                    Lord Hasan wrote:

                    if that is right ... what's the BLL ...

                    Business rules. Entity classes. For example, if you have a Person class, and a Person has a Role property, the database would return the Role, and set the Role in the DB. The BLL would decide when the Role changed, and what it changed to. The Person class would be in the business layer. The data access would be calls from the person class to the persondatalayer class. The way that a Person looked on the screen, would be the presentation layer. If you clicked on a button that said 'set rol to Admin', the presentation layer would create an instance of the Person class, and call a method to set the Role, which would then call the data layer, so your code has moved through the three layers, each has it's area of responsibility.

                    Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

                    H 1 Reply Last reply
                    0
                    • C Christian Graus

                      Lord Hasan wrote:

                      know alittle UML

                      You're ahead of me, I know none...

                      Lord Hasan wrote:

                      but in DAL i should create a class , who has attributes the feild of the table and who has methods like add,delete,update,...

                      I'd create a datalayer class for each object that calls it, so if you have a Person class, have a PersonDataLayer class. This class will return and accept Person objects, and each method exposed will map to a stored proc.

                      Lord Hasan wrote:

                      these methode calls stored procedures, on opening a connection, calling the procedure, putting the data in a data set, closing the connection, returning the dataset ??? that what i made before ... so is this right ?

                      You can return datasets, or you can return entity objects. Returning entity objects is prettier, but on complex systems, in the absence of friend classes, can make keeping things OO a little difficult. Either way will work fine.

                      Lord Hasan wrote:

                      if that is right ... what's the BLL ...

                      Business rules. Entity classes. For example, if you have a Person class, and a Person has a Role property, the database would return the Role, and set the Role in the DB. The BLL would decide when the Role changed, and what it changed to. The Person class would be in the business layer. The data access would be calls from the person class to the persondatalayer class. The way that a Person looked on the screen, would be the presentation layer. If you clicked on a button that said 'set rol to Admin', the presentation layer would create an instance of the Person class, and call a method to set the Role, which would then call the data layer, so your code has moved through the three layers, each has it's area of responsibility.

                      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

                      H Offline
                      H Offline
                      Hasan Jaffal
                      wrote on last edited by
                      #10

                      so i create classes then for each class i made a datalayerclasse then in the application i make instances frome the classes not from their datalayer calsses example class persone id as integer name as string age as integer ap as appartment public function get_person(i as integer) as persone dim p as personedatalayer return p.getdataperson(i) end function and class personedatalayer public function get_getdataperson(i as integer) as persone dim ds as new dataset con.open() .... calling stored procedure con.close() return ds.tables(0).row(0) end function is this right ? if it's right so how to return a set of persons ?

                      C 1 Reply Last reply
                      0
                      • H Hasan Jaffal

                        so i create classes then for each class i made a datalayerclasse then in the application i make instances frome the classes not from their datalayer calsses example class persone id as integer name as string age as integer ap as appartment public function get_person(i as integer) as persone dim p as personedatalayer return p.getdataperson(i) end function and class personedatalayer public function get_getdataperson(i as integer) as persone dim ds as new dataset con.open() .... calling stored procedure con.close() return ds.tables(0).row(0) end function is this right ? if it's right so how to return a set of persons ?

                        C Offline
                        C Offline
                        Christian Graus
                        wrote on last edited by
                        #11

                        Lord Hasan wrote:

                        return ds.tables(0).row(0)

                        That's not going to work. You need to create a new Persone instance and populate it, either with properties or a constructor.

                        Lord Hasan wrote:

                        dim p as personedatalayer

                        You also need to call 'new'. I'd just make the methods static ( shared ). A 'get person' method would also be shared. You don't need to create a person to create a person, that makes no sense.

                        Lord Hasan wrote:

                        so how to return a set of persons ?

                        Well, your code can do one of two things. 1 - populate a persone instance in the datalayer from the datarow 2 - return the datarow and have your object populate itself from that. I lean towards 2, as 1 tends to break encapsulation, in my experience. There are other ways to go about it, but broadly, that's what will have to happen.

                        Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

                        H 1 Reply Last reply
                        0
                        • C Christian Graus

                          Lord Hasan wrote:

                          return ds.tables(0).row(0)

                          That's not going to work. You need to create a new Persone instance and populate it, either with properties or a constructor.

                          Lord Hasan wrote:

                          dim p as personedatalayer

                          You also need to call 'new'. I'd just make the methods static ( shared ). A 'get person' method would also be shared. You don't need to create a person to create a person, that makes no sense.

                          Lord Hasan wrote:

                          so how to return a set of persons ?

                          Well, your code can do one of two things. 1 - populate a persone instance in the datalayer from the datarow 2 - return the datarow and have your object populate itself from that. I lean towards 2, as 1 tends to break encapsulation, in my experience. There are other ways to go about it, but broadly, that's what will have to happen.

                          Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

                          H Offline
                          H Offline
                          Hasan Jaffal
                          wrote on last edited by
                          #12

                          hi man h r u ? what i wrote it's the idea not the code but the real code the i wrote is Public Class Dossier Private MyNum As Integer Private MyArrivageDate As DateTime Sub New() MyNum = New Integer ArrivageDate = New DateTime(1900, 1, 1) End Sub Public Property Numero() Get Return MyNum End Get Set(ByVal Value) MyNum = Value End Set End Property Public Property ArrivageDate() Get Return MyArrivageDate End Get Set(ByVal Value) MyArrivageDate = Value End Set End Property Public Function GetDossier(ByVal DossierNum) As Dossier Try Dim D As New DA_Dossier Return D.GetDossier(DossierNum) Catch e As Exception MsgBox(e.ToString(), MsgBoxStyle.Critical, "Erreur") End Try End Function Public Function GetAllDossiers() As Dossier() Try Dim D As New DA_Dossier Return D.GetAllDossiers() Catch e As Exception MsgBox(e.ToString(), MsgBoxStyle.Critical, "Erreur") End Try End Function End Class ------------------------------------------------------------------------------- Public Class DA_Dossier Public Function GetDossier(ByVal DossierNum) As Dossier Try Dim MySQLCommand As New SqlClient.SqlCommand("Select_Dossier ' * ','DossierID=" & DossierNum & "','',''", MySQLConnection) Dim MySQLDataAdapter As New SqlClient.SqlDataAdapter(MySQLCommand) Dim MyDataSet As New DataSet Dim D As New Dossier MySQLConnection.Open() MySQLDataAdapter.Fill(MyDataSet) MySQLConnection.Close() If MyDataSet.Tables(0).Rows.Count <> 0 Then D.Numero = MyDataSet.Tables(0).Rows(0)(0) D.ArrivageDate = MyDataSet.Tables(0).Rows(0)(1) End If Return D Catch e As Exception MsgBox(e.ToString(), MsgBoxStyle.Critical, "Erreur") If MySQLConnection.State = ConnectionState.Open Then MySQLConnection.Close() End If End Try End Function Public Function GetAllDossiers() As Dossier() Try Dim MySQLCommand As New SqlClient.SqlCommand("Select_Dossier ' * ','','',''", MySQLConnection) Dim MySQLDataAdapter As New SqlClient.SqlDataAdapter(MySQLC

                          H C 2 Replies Last reply
                          0
                          • H Hasan Jaffal

                            hi man h r u ? what i wrote it's the idea not the code but the real code the i wrote is Public Class Dossier Private MyNum As Integer Private MyArrivageDate As DateTime Sub New() MyNum = New Integer ArrivageDate = New DateTime(1900, 1, 1) End Sub Public Property Numero() Get Return MyNum End Get Set(ByVal Value) MyNum = Value End Set End Property Public Property ArrivageDate() Get Return MyArrivageDate End Get Set(ByVal Value) MyArrivageDate = Value End Set End Property Public Function GetDossier(ByVal DossierNum) As Dossier Try Dim D As New DA_Dossier Return D.GetDossier(DossierNum) Catch e As Exception MsgBox(e.ToString(), MsgBoxStyle.Critical, "Erreur") End Try End Function Public Function GetAllDossiers() As Dossier() Try Dim D As New DA_Dossier Return D.GetAllDossiers() Catch e As Exception MsgBox(e.ToString(), MsgBoxStyle.Critical, "Erreur") End Try End Function End Class ------------------------------------------------------------------------------- Public Class DA_Dossier Public Function GetDossier(ByVal DossierNum) As Dossier Try Dim MySQLCommand As New SqlClient.SqlCommand("Select_Dossier ' * ','DossierID=" & DossierNum & "','',''", MySQLConnection) Dim MySQLDataAdapter As New SqlClient.SqlDataAdapter(MySQLCommand) Dim MyDataSet As New DataSet Dim D As New Dossier MySQLConnection.Open() MySQLDataAdapter.Fill(MyDataSet) MySQLConnection.Close() If MyDataSet.Tables(0).Rows.Count <> 0 Then D.Numero = MyDataSet.Tables(0).Rows(0)(0) D.ArrivageDate = MyDataSet.Tables(0).Rows(0)(1) End If Return D Catch e As Exception MsgBox(e.ToString(), MsgBoxStyle.Critical, "Erreur") If MySQLConnection.State = ConnectionState.Open Then MySQLConnection.Close() End If End Try End Function Public Function GetAllDossiers() As Dossier() Try Dim MySQLCommand As New SqlClient.SqlCommand("Select_Dossier ' * ','','',''", MySQLConnection) Dim MySQLDataAdapter As New SqlClient.SqlDataAdapter(MySQLC

                            H Offline
                            H Offline
                            Hasan Jaffal
                            wrote on last edited by
                            #13

                            sory that wasn't work in the buton the array should be static and this is a problem

                            1 Reply Last reply
                            0
                            • H Hasan Jaffal

                              hi man h r u ? what i wrote it's the idea not the code but the real code the i wrote is Public Class Dossier Private MyNum As Integer Private MyArrivageDate As DateTime Sub New() MyNum = New Integer ArrivageDate = New DateTime(1900, 1, 1) End Sub Public Property Numero() Get Return MyNum End Get Set(ByVal Value) MyNum = Value End Set End Property Public Property ArrivageDate() Get Return MyArrivageDate End Get Set(ByVal Value) MyArrivageDate = Value End Set End Property Public Function GetDossier(ByVal DossierNum) As Dossier Try Dim D As New DA_Dossier Return D.GetDossier(DossierNum) Catch e As Exception MsgBox(e.ToString(), MsgBoxStyle.Critical, "Erreur") End Try End Function Public Function GetAllDossiers() As Dossier() Try Dim D As New DA_Dossier Return D.GetAllDossiers() Catch e As Exception MsgBox(e.ToString(), MsgBoxStyle.Critical, "Erreur") End Try End Function End Class ------------------------------------------------------------------------------- Public Class DA_Dossier Public Function GetDossier(ByVal DossierNum) As Dossier Try Dim MySQLCommand As New SqlClient.SqlCommand("Select_Dossier ' * ','DossierID=" & DossierNum & "','',''", MySQLConnection) Dim MySQLDataAdapter As New SqlClient.SqlDataAdapter(MySQLCommand) Dim MyDataSet As New DataSet Dim D As New Dossier MySQLConnection.Open() MySQLDataAdapter.Fill(MyDataSet) MySQLConnection.Close() If MyDataSet.Tables(0).Rows.Count <> 0 Then D.Numero = MyDataSet.Tables(0).Rows(0)(0) D.ArrivageDate = MyDataSet.Tables(0).Rows(0)(1) End If Return D Catch e As Exception MsgBox(e.ToString(), MsgBoxStyle.Critical, "Erreur") If MySQLConnection.State = ConnectionState.Open Then MySQLConnection.Close() End If End Try End Function Public Function GetAllDossiers() As Dossier() Try Dim MySQLCommand As New SqlClient.SqlCommand("Select_Dossier ' * ','','',''", MySQLConnection) Dim MySQLDataAdapter As New SqlClient.SqlDataAdapter(MySQLC

                              C Offline
                              C Offline
                              Christian Graus
                              wrote on last edited by
                              #14

                              Lord Hasan wrote:

                              .Numero = MyDataSet.Tables(0).Rows(i)(0) .ArrivageDate = MyDataSet.Tables(0).Rows(i)(1)

                              You should grab columns by name, not by index.

                              Lord Hasan wrote:

                              but now i feel that the class dossier isn't important it just call the dossierdatalayer class so what's its importance

                              Well, it depends. This is really a struct right now, but over time, most business layer classes will have methods that do mmore than just call data access methods. They will also contain business rules, such as deciding what state an object is in ( which the data layer will then save ).

                              Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

                              H 1 Reply Last reply
                              0
                              • C Christian Graus

                                Lord Hasan wrote:

                                .Numero = MyDataSet.Tables(0).Rows(i)(0) .ArrivageDate = MyDataSet.Tables(0).Rows(i)(1)

                                You should grab columns by name, not by index.

                                Lord Hasan wrote:

                                but now i feel that the class dossier isn't important it just call the dossierdatalayer class so what's its importance

                                Well, it depends. This is really a struct right now, but over time, most business layer classes will have methods that do mmore than just call data access methods. They will also contain business rules, such as deciding what state an object is in ( which the data layer will then save ).

                                Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

                                H Offline
                                H Offline
                                Hasan Jaffal
                                wrote on last edited by
                                #15

                                so what i did is the correct structure of an n-tier application Data layer DAL BLL Presentation layer so thanks for the help ... u r gr8 man

                                H 1 Reply Last reply
                                0
                                • H Hasan Jaffal

                                  so what i did is the correct structure of an n-tier application Data layer DAL BLL Presentation layer so thanks for the help ... u r gr8 man

                                  H Offline
                                  H Offline
                                  Hasan Jaffal
                                  wrote on last edited by
                                  #16

                                  hello again man we have now a new problem with this structure i'm doing that but the application became so slow !! espacilly by filling listviews and combos WHY we don't use ADO.NET things, like data sets and bind them in a listview !!! i'm comfused !!!

                                  " I love deadlines. I like the whooshing sound they make as they fly by. "

                                  1 Reply Last reply
                                  0
                                  Reply
                                  • Reply as topic
                                  Log in to reply
                                  • Oldest to Newest
                                  • Newest to Oldest
                                  • Most Votes


                                  • Login

                                  • Don't have an account? Register

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular
                                  • World
                                  • Users
                                  • Groups