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. General Programming
  3. C#
  4. help on project

help on project

Scheduled Pinned Locked Moved C#
csharphelpcom
9 Posts 6 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
    himanshu p taunk
    wrote on last edited by
    #1

    my problem is most of my project winfrm/webfrm (C#.net) takes too much time to start and to operate. do you think I have to change my programming style. if you have any thing to say about it or have any sample project to study on PLEASE fell free to mail me at :- hptaunk@gmail.com I will be very glad to you. thanks

    himanshu p.taunk

    C J 2 Replies Last reply
    0
    • H himanshu p taunk

      my problem is most of my project winfrm/webfrm (C#.net) takes too much time to start and to operate. do you think I have to change my programming style. if you have any thing to say about it or have any sample project to study on PLEASE fell free to mail me at :- hptaunk@gmail.com I will be very glad to you. thanks

      himanshu p.taunk

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

      How long is too long ? What does your app do on startup ? The .NET framework takes a while to initialise, a web app especially, will take a long time to start on first access, then be nice and fast.

      Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      1 Reply Last reply
      0
      • H himanshu p taunk

        my problem is most of my project winfrm/webfrm (C#.net) takes too much time to start and to operate. do you think I have to change my programming style. if you have any thing to say about it or have any sample project to study on PLEASE fell free to mail me at :- hptaunk@gmail.com I will be very glad to you. thanks

        himanshu p.taunk

        J Offline
        J Offline
        J4amieC
        wrote on last edited by
        #3

        himanshu p taunk wrote:

        my problem is most of my project winfrm/webfrm (C#.net) takes too much time to start and to operate.

        I have no idea what this means!

        himanshu p taunk wrote:

        do you think I have to change my programming style.

        Being that you have not hinted at what your current "programming style" is, how is anyone supposed to advise you on whether to change?

        himanshu p taunk wrote:

        if you have any thing to say about it or have any sample project to study on

        There are thousands upon thousands of C# projects redily available on the net to study how others program things.... any reason why you need someone else to do the google search for you?

        himanshu p taunk wrote:

        PLEASE fell free to mail me

        The general idea of forums is that they are public and everyone gets to learn... by mailing you directly this is not possible. Post a message to a forum get a response on the forum... thats the way we play this game.

        --- How to get answers to your questions[^]

        H 1 Reply Last reply
        0
        • J J4amieC

          himanshu p taunk wrote:

          my problem is most of my project winfrm/webfrm (C#.net) takes too much time to start and to operate.

          I have no idea what this means!

          himanshu p taunk wrote:

          do you think I have to change my programming style.

          Being that you have not hinted at what your current "programming style" is, how is anyone supposed to advise you on whether to change?

          himanshu p taunk wrote:

          if you have any thing to say about it or have any sample project to study on

          There are thousands upon thousands of C# projects redily available on the net to study how others program things.... any reason why you need someone else to do the google search for you?

          himanshu p taunk wrote:

          PLEASE fell free to mail me

          The general idea of forums is that they are public and everyone gets to learn... by mailing you directly this is not possible. Post a message to a forum get a response on the forum... thats the way we play this game.

          --- How to get answers to your questions[^]

          H Offline
          H Offline
          himanshu p taunk
          wrote on last edited by
          #4

          my mistake sorry most of my program takes too much time to connect a database (SQL Express /MS Access) making my application to response slow. i access my database using a class where i have declare my statements (currently i am working on vb Project) this is the code i usto access to database do u find any problem with it '''''' Imports System Imports System.Data Imports System.Data.OleDb Public Class dbtask Public Sub New() End Sub Public ReadOnly Property Connection() As OleDbConnection Get Try Return New OleDbConnection(Configuration.ConfigurationManager.AppSettings(0).ToString()) Catch ex As Exception Throw New Exception("OleDbConnection : " & ex.Message) End Try End Get End Property Public Function ExecuteCommand(ByVal statement As String) As DataTable Try Dim adp As New OleDbDataAdapter(statement, Connection()) Dim ds As New DataSet ds.Clear() adp.Fill(ds) ' MsgBox("-->" & ds.Tables.Count) Return ds.Tables(0) Catch ex As Exception Connection.Close() 'Throw New Exception("Oledb Execute Command : " & ex.Message) Return Nothing End Try End Function Public Sub ExecuteNonCommand(ByVal statement As String) Dim cmd As New OleDbCommand(statement, Connection()) Try cmd.Connection.Open() cmd.ExecuteNonQuery() cmd.Connection.Close() Catch ex As Exception cmd.Connection.Close() Throw New Exception("Oledb Execute Non Command : " & ex.Message) End Try End Sub End Class

          himanshu p.taunk

          R G 2 Replies Last reply
          0
          • H himanshu p taunk

            my mistake sorry most of my program takes too much time to connect a database (SQL Express /MS Access) making my application to response slow. i access my database using a class where i have declare my statements (currently i am working on vb Project) this is the code i usto access to database do u find any problem with it '''''' Imports System Imports System.Data Imports System.Data.OleDb Public Class dbtask Public Sub New() End Sub Public ReadOnly Property Connection() As OleDbConnection Get Try Return New OleDbConnection(Configuration.ConfigurationManager.AppSettings(0).ToString()) Catch ex As Exception Throw New Exception("OleDbConnection : " & ex.Message) End Try End Get End Property Public Function ExecuteCommand(ByVal statement As String) As DataTable Try Dim adp As New OleDbDataAdapter(statement, Connection()) Dim ds As New DataSet ds.Clear() adp.Fill(ds) ' MsgBox("-->" & ds.Tables.Count) Return ds.Tables(0) Catch ex As Exception Connection.Close() 'Throw New Exception("Oledb Execute Command : " & ex.Message) Return Nothing End Try End Function Public Sub ExecuteNonCommand(ByVal statement As String) Dim cmd As New OleDbCommand(statement, Connection()) Try cmd.Connection.Open() cmd.ExecuteNonQuery() cmd.Connection.Close() Catch ex As Exception cmd.Connection.Close() Throw New Exception("Oledb Execute Non Command : " & ex.Message) End Try End Sub End Class

            himanshu p.taunk

            R Offline
            R Offline
            Rocky
            wrote on last edited by
            #5

            First thing!! look at the name of the forum and the code u've posted? See anything?? and well incase if your applications are taking time to initialize things... you should consider using a splash Screen at the start just like MS word has. and do ur initializations on another thread while the window is there. There are a few articles here as well... search for it. Thanks

            Rocky You can't climb up a ladder with your hands in your pockets.

            1 Reply Last reply
            0
            • H himanshu p taunk

              my mistake sorry most of my program takes too much time to connect a database (SQL Express /MS Access) making my application to response slow. i access my database using a class where i have declare my statements (currently i am working on vb Project) this is the code i usto access to database do u find any problem with it '''''' Imports System Imports System.Data Imports System.Data.OleDb Public Class dbtask Public Sub New() End Sub Public ReadOnly Property Connection() As OleDbConnection Get Try Return New OleDbConnection(Configuration.ConfigurationManager.AppSettings(0).ToString()) Catch ex As Exception Throw New Exception("OleDbConnection : " & ex.Message) End Try End Get End Property Public Function ExecuteCommand(ByVal statement As String) As DataTable Try Dim adp As New OleDbDataAdapter(statement, Connection()) Dim ds As New DataSet ds.Clear() adp.Fill(ds) ' MsgBox("-->" & ds.Tables.Count) Return ds.Tables(0) Catch ex As Exception Connection.Close() 'Throw New Exception("Oledb Execute Command : " & ex.Message) Return Nothing End Try End Function Public Sub ExecuteNonCommand(ByVal statement As String) Dim cmd As New OleDbCommand(statement, Connection()) Try cmd.Connection.Open() cmd.ExecuteNonQuery() cmd.Connection.Close() Catch ex As Exception cmd.Connection.Close() Throw New Exception("Oledb Execute Non Command : " & ex.Message) End Try End Sub End Class

              himanshu p.taunk

              G Offline
              G Offline
              Guffa
              wrote on last edited by
              #6

              That code is not very good. You are opening a new database connection for every single query you run, which is just a waste of resources. Even worse, the ExecuteCommand method opens a connection that is never closed. Only if there was an exception the code closes a connection, but that is not the connection that was open earlier. Instead it opens a completely new connection that is immediately closed. The ExecuteCommand is bad in another way. It catches any type of exception, discards it and just return an unusable value. If you catch exceptions, only catch the ones that you handle, and really handle the ones that you catch.

              --- single minded; short sighted; long gone;

              B 1 Reply Last reply
              0
              • G Guffa

                That code is not very good. You are opening a new database connection for every single query you run, which is just a waste of resources. Even worse, the ExecuteCommand method opens a connection that is never closed. Only if there was an exception the code closes a connection, but that is not the connection that was open earlier. Instead it opens a completely new connection that is immediately closed. The ExecuteCommand is bad in another way. It catches any type of exception, discards it and just return an unusable value. If you catch exceptions, only catch the ones that you handle, and really handle the ones that you catch.

                --- single minded; short sighted; long gone;

                B Offline
                B Offline
                Brady Kelly
                wrote on last edited by
                #7

                Guffa wrote:

                That code is not very good. You are opening a new database connection for every single query you run, which is just a waste of resources.

                Connection pooling should take care of that.

                G 1 Reply Last reply
                0
                • B Brady Kelly

                  Guffa wrote:

                  That code is not very good. You are opening a new database connection for every single query you run, which is just a waste of resources.

                  Connection pooling should take care of that.

                  G Offline
                  G Offline
                  Guffa
                  wrote on last edited by
                  #8

                  Connection pooling helps a lot, but it's still a waste of resources to open and close connections over and over again. Besides, if you don't close the connections, even the pooling can't save you.

                  --- single minded; short sighted; long gone;

                  H 1 Reply Last reply
                  0
                  • G Guffa

                    Connection pooling helps a lot, but it's still a waste of resources to open and close connections over and over again. Besides, if you don't close the connections, even the pooling can't save you.

                    --- single minded; short sighted; long gone;

                    H Offline
                    H Offline
                    himanshu p taunk
                    wrote on last edited by
                    #9

                    what changes you want me to do, to make it work well

                    himanshu p.taunk

                    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