help on project
-
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
-
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
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 )
-
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
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.
-
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.
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
-
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
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.
-
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
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;
-
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;
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.
-
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.
-
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;
what changes you want me to do, to make it work well
himanshu p.taunk