|
That's a HUGE bad practice. In an SQL Servce environment, you've just grabbed a very expensive connection license and are holding it indefinitely. That connection won't be doing anything for about 95% of the lifetime of your app. Does that sound like a good use for a license that costs $$$??
You also didn't solve the problem. You merely got around it by opening the connection once, which will probably have that delay.
What does the connection string look like?? How are you opening the connection when you want to make a query?? How are you USING the connection?? Is it being closed properly when you're done with it??
|
|
|
|
|
Let me clarify this a little bit. We are using SQL 2005 Express. No licenses needed here. Actually what I'm doing in our application is we have a wrapper class that encapsulates all the data access functionality throughout the program. (Execute, ExecuteScalar, ExecuteNonQuery, ...) Additionally we have functions that return datasets and update datasets) Our program can run on a local database or through web services to our hosted databases. I have a global variable (g_Data) that is an instance of our wrapper class. When this class is initialized a connection to the database is made and when the class is disposed the connection is closed. What I have found when using the SQL Express is that when opening connections, running a command, then closing right away a bottleneck occurs when several calls are made back to back to the database because SQL Express does not handle multiple connections at a time. It hangs and waits for a connection to close before continuing. I forgot to mention our program is multithreaded. It has a few background threads that run and perform various maintenance routines. These maintenance routines require data access so if one of the threads has a hold of a connection then the user will experience a wait and often times will get a "program not responding" message in the title bar. When I changed the wrapper class so that only one connection was made upon initialization and all sub sequential commands run through that connection. The problem went away.
|
|
|
|
|
nathan22405 wrote: Let me clarify this a little bit. We are using SQL 2005 Express. No licenses needed here
Not yet. But if you apply the same solution to a full SQL Server database, or if you existing app is scaled up to the full version, your "solution" would get you escorted to the door pretty quick.
nathan22405 wrote: What I have found when using the SQL Express is that when opening connections, running a command, then closing right away a bottleneck occurs when several calls are made back to back to the database
I've never run into the problem, doing just that.
nathan22405 wrote: SQL Express does not handle multiple connections at a time.
Wanna bet? SQL Server Express doesn't have a connection limit, other than machine resources. It uses the same communications engine as the full SQL Server.
It's possible that your code, or connection string, isn't allowing ADO.NET to cache/pool connections or is not doing it efficiently.
|
|
|
|
|
I will look more into this. Thank You. On my development machine I in fact do connect to our Full SQL Server 2005 and did not have these issues even prior to the change I made. It was only when connecting to the SQL Express upon deployment on the cutomers machine. Would the fact that it connects by attaching at runtime have any effect on this? I am new to using SQL Express.
|
|
|
|
|
Hello
How can i move a rectangle with Mouse on C# form.
|
|
|
|
|
By handling the mouse move event and invalidating the form in there, then drawing the rectangle in your paint event.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Ask a simple question, get a simple answer...
It has become appallingly obvious that our technology has exceeded our humanity. - Albert Einstein
|
|
|
|
|
hi all,
please help me in this problem.how can we import data from excel sheet to ms access database table .i am using c# windows application.
thank you.
regards
obalesu n
|
|
|
|
|
Access can import an excel spreadsheet directly, without using C#. If you go to the File/Get External Data/Import menu you will see that one of the file types is Excel. This is in Excel XP, I do not have Excel 2007 but I assume it will be the same.
Hopefully this will solve your problem.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
thank you. and i have faced another problem in my windows application(c#,ms access).i am using backend as ms access.i have written code like this.
string s="datasource=C:\\cms\\cmsaccess.mdb";
string q="select * from users";
OledbConnection con=new OledbConnection(s);
OledbDataAdapter adp=new OledbDataAdapter(q,con);
DataSet ds=new DataSet();
adp.fill(ds,"users");
i have written like this in every form .but if i installed in server how the application access that database(C:\\cms\\cmsaccess.mdb) in clients .the database location may be changed in clients.i am facing this problem. this application must be run in network.please send solution for this problem.
thank you
regards
obalesu n
|
|
|
|
|
Put the mdb file on a network drive. Put the mdb file location in the app.config file, using a unc path - not 100% sure if a unc path will work, if not map a drive - google for net use
Alternatively put the whole lot on the network and just give the users a shortcut
You may experience performance problems if you have many users,Access is not designed to have lots of users, I would suggest if you are expecting more than about 10 or expect a lot of insert/update activity move to another type of database, for example sql server or mysql
Hope this helps
Bob
Ashfield Consultants Ltd
|
|
|
|
|
thanks for reply
dear sir i don't have any idea about config file.and i wrote connectionstring as"datasource =C:\\cms\\cms.xls" .please send clearly idid't yet solve this problem.
thank you
regards
obalesu
|
|
|
|
|
obalesu wrote: i don't have any idea about config file
In which case try the C# help.
obalesu wrote: i wrote connectionstring as"datasource =C:\\cms\\cms.xls"
This will only work if your excel file is on your C drive. You said its on the network, so it won't work will it.
I suggest you try a bit of Google research
Bob
Ashfield Consultants Ltd
|
|
|
|
|
I have an editor for designing flat file layouts. The editor operates on an ExportSection, a layout specification for one text file, as its model, using a DataGridView as a presenter for the line layouts in the section. It has section header and footer groups, which appear before and after all the export lines, respectively. It also allows a single group header and footer, which appear before and after each set of records in a group, e.g. line items per invoice number. Each section has 0 to many lines.
Now I have various commands for the user to edit the file layout, and I would please like some suggestions as to making these commands as intuitively accessible to even very novice users. At the moment I only have a top menu bar, and some ugly, un-iconned buttons at the top of the editor. The command set is:
Main Section Menu.
1. Insert section header.
2. Insert group header.
3. Insert group detail.
4. Insert group footer.
5. Insert section footer.
Once a user has created the groups they require, e.g section header and group detail for a simple file, they can add more lines to a group by highlighting a cell in that group, and clicking the Add Line button. The other operations that are then available are:
1. Move cell left.
2. Move cell right.
3. Move line down.
4. Move line up.
5. Insert a column right of the current column.
6. Insert a column left of the current column.
7. Delete the current column.
8. Delete the current line.
9. Cut copy and paste cells or whole lines.
I want to use some sort of view that e.g. for commands 1 to 4 in the second list, I'd like a Move panel or something that nicely groups all the move buttons or menu options, and the same for inserts and deletes. I need something instantly visible and accessible to the users, in addition to having these commands available on right-click context menus. I'll probably end up designing my own icons for the buttons, but I'm not sure if simply buttons is the way to go. I want to find something newish, maybe a ribbon (gasp) or something that displays command sets based on context. Any suggestions at all would be welcome.
|
|
|
|
|
Hi,
How do I decide whether I've to use a Windows scheduler or a Timer to run a process.
i.e, I have a windows form, which writes an XML file after querying our Database at pre-set interval. What should I use in this scenario, a Timer control (System.Timers.Timer) or a Windows service to run this process?
Regards,
Blumen
|
|
|
|
|
What about using the actual Windows Scheduler to fire off your application? Using a timer (System.Timers.Timer) means your application is running all the time and using computer resources. Then you have the problem of monitoring to ensure it is still running (often called heartbeating). This applies whether you have a form running with a timer to kick off the query or a Windows Service to do it. Windows Services are really meant for applications that need to constantly monitor for events (such as files arriving), again using a tmer means you need to check the application is still running, it will be using resources etc.
I hope this helps.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Hi Bob,
Thanks for the information. My application would be periodically querying employee database and creating xml files if new employee is created.
Regards,
Blumen
|
|
|
|
|
You are welcome. If you are periodically checking the database, depending on the frequency, I would probably go for a Windows Service. You need to consider the frequency of check and cost of starting the application.
Hope this helps
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Thanks Bob, I appreciate it.
|
|
|
|
|
The desktop support guys here have asked me to put together an application that can display info while a screen is locked (mostly XP machines but a few Vistas as well).
So far I'm only aware of 2 ways of interacting with a locked machine: the background image (like bginfo) and under certain conditions using extended keys (such as the volume keys on some keyboards).
I'd like to use a combination of the 2 (i.e. press an extended key and change the background image with the required data) but I can't guarantee that every user will have an extended keyboard or that their machine configuration will even allow this.
Does anyone know any other ways of interacting with the machine while the screen is locked? Lateral thinkers welcome!!
|
|
|
|
|
How about setting up the machine to show a screensaver, which will show while it's locked, and the screensaver can respond to key board events to show differnt things ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Good idea, the only caveat being not everyone uses a screensaver (I just blank my screen after 5 minutes).
It looks like I may need to implement a suite covering all possibilities.
|
|
|
|
|
You could make you program change the screen saver settings, and if necessary, change the power options to not turn off the monitor(not good for laptops on battery).
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
i want to accept the value 123.45 but
when i enter the value 123.4.5 , it accepts the value.
i have set format
inputmaxlength as 10
DefaultCellStyle.Format ########.##
In the keypreess event i have set to accept only integer and deceimal values.
so How to set to accept only in the first format i.e 123.45 and not 123.4.5
Thank you
vijaya
|
|
|
|
|
The DataGridView has a CellValidating event which is raised when a cell loses the focus. If you take a look at the MSDN documentation for it, there's a sample that shows how to validate the entry. The example looks at validating for an integer, but if you use double.TryParse instead it should do what you want.
|
|
|
|