|
Thanks very much for the reply.
1.) I agree whole-heartedly. Excel is not a database, I am just trying to get something up and running while I learn MySQL and implement. The spreadsheet is already in place, and I had hoped to get something quick and dirty up and running for those who utilize it... and then come back later and move the program to SQL. (under a time crunch).
2.) In this case, I have a dataset.. should I just move through the dataset itself (make this a public variable?) and just use the DataGridView to display the data?
3.) I checked this... and I set the value right above this... I have checked it using a breakpoint and the index I provide is valid... its just the datagridView that seems to 'lose' rows. Could this be a private vs. public variable issue?
|
|
|
|
|
Take a look at this article[^], it is designed to service the user control but may give you some ideas around the DGV, it uses an XML datasource.
Also look into the use of the bindingsource in the article, adds another layer but is quite useful.
Remember do NOT allow your users to do inline editing in a list control (DGV, listview). I force the user to a dialog for CRUD, supply a toolstrip with Add/Edit/Delete, double click the grid also does Edit. Pop a dialog with selected or blank record for the add/edit, write back to your data store before closing the dialog and reload the grid on a successful CRUD.
This may not suit the purist because there are multiple I/O to the database but it works very well and you can never lost data.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Is it true that,the database of Visual studio 2008 can't work with sql server 2008?
if it is false,
I want to connect to the sql server 2008 so I can connect but it doesn't work.
|
|
|
|
|
I was going to reply that VS does not have a database but realised you may mean the database designer, it certainly does connect to VS 2008 (although I never use it there would have been a LOT of noise if it didn't connect to sql server 2008).
Have a look through Connectionstrings.com for the syntax and search for some articles on connection to SQL Server
|
|
|
|
|
Their is no reason that it will not work , it works , but question here is worked means connectivity or something else
Best Of Regards,
SOFTDEV
If you have knowledge, let others light their candles at it
|
|
|
|
|
Hello all,
I am trying to execute following query but getting an error as amount us not a valid column:
select itemname,rate,qty,discount,(rate * qty) as amount,(amount -(amount * (disount/100))) as Total from ItemMaster;
Then i try:
select itemname,rate,qty,discount,(rate * qty) as amount,((rate * qty) - ((rate * qty) * (disount/100))) as Total from ItemMaster;
and it worked fine.
I need to execute queries which involves more complex expressions within them.
My doubt is, is there any way to run query by first method so that we don't need to write complex expressions again and again?
Thanks,
Nagendra.
|
|
|
|
|
try making Sql Server UDF (User Defined Functions)
Best Of Regards,
SOFTDEV
If you have knowledge, let others light their candles at it
|
|
|
|
|
There are a number of methods to achieve a semblance of this, UDF is one, in the above simplistic sample on you could create a view that calcs the amount column, you could create a table variable to hold the equivalent of the view, this would only be valid for the current proc whereas a view persists to the database.
I am in the habit of creating a view for my transaction tables, creating any calculated columns (amount) and joining to the foreign key tables (an example would be an OrderLine to Product table on the ProductID to get the product name in the view).
|
|
|
|
|
I agree with you View will be a good option
Best Of Regards,
SOFTDEV
If you have knowledge, let others light their candles at it
|
|
|
|
|
I would go with the view approach, a UDF can add a large overhead to a simple query, slowing it right down - much more than you would expect.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
HI
I want to Access SQL Server database from network. What are the configure made in sql server ... If have any step please share with me ... or give proper Url for this scenario...
Thankyou
|
|
|
|
|
What problem are you facing.
Best Of Regards,
SOFTDEV
If you have knowledge, let others light their candles at it
|
|
|
|
|
Take a look at connectionstrings.com.
What you have asked cannot be answered by a simple forum post, you need to do some reading and possibly a specialist site may help, SQLServerCentral.com is very useful.
This search of articles[^] turns up some interesting titles as well
|
|
|
|
|
Hi..
1) I was trying to create a IF Condition in stored procedure where i need to compare if old value and new value is present/not present in the database. Dont know the Syntax to write the above said query in Stored procedure.
2) I have created a variabl name 'add', 'change', 'remove'. The old value and new value are two different columns in the table. What i want is : If old value is null and new value is present then 'add' get incremented by 1, if old value is present and it has been modified in new value and if the old value string does not match with the new value then 'change' get incremented by 1, if old value is present and it has bee deleted in new value then 'remove' get incremented by 1.
Kindly help me out as early as possible as these is where i stuck for the last few days and i need to resolve this soon.
Abhishek
|
|
|
|
|
Congradulations, you found the correct forum to post a database question to. Now remove the one in the ASP.NET before someone answers there.
only two letters away from being an asset
|
|
|
|
|
IF( EXISTS(SELECT ?? FROM [Table] WHERE ??? ) )
And this has had you stuck for days?
only two letters away from being an asset
|
|
|
|
|
Can you post what your database table looks like, and when you want to run this "proces" ie. is it when you update a row? How do you currently update the row? Is there just Old Value and NerwValue in the table?
This question has a lot of detail, but is very confusing. As usual, please post what you have so far in the way of code.
|
|
|
|
|
My application currently opens its data base connection when it starts, and closes it when it exits. The application runs for long periods (days or even weeks). The problem lies in that it accesses the data base infrequently. Accesses may be minutes or even hours apart in time. In other instances, there may be several accesses within a few milliseconds of each other.
At some sites, it appears that the data base server (SQL Server 2005) is dropping the connection because my application is not keeping up a steady traffic of operations.
One option would be for me to change my code to open the data base connection, perform the operation, and close the connection, for each and every data base transaction.
This approach seems clumsy, however. Does anyone have any better suggestions?
Software Zen: delete this;
|
|
|
|
|
Gary Wheeler wrote: Does anyone have any better suggestions?
No. AFAIK open-use-close is the normal pattern. And connection pooling takes care of most performance issues that result from frequent opens/closes.
[ADDED] The above applies when using .NET Framework.[/ADDED]
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? Neen!
modified on Thursday, October 8, 2009 7:47 AM
|
|
|
|
|
Thanks, Luc!
I had a feeling that was the case, but thought I would make sure.
Software Zen: delete this;
|
|
|
|
|
you're welcome.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
will always prefer disconnected architecture means connect to db when their is needs to connect to db mostly in CRUD operations.
Best Of Regards,
SOFTDEV
If you have knowledge, let others light their candles at it
|
|
|
|
|
You could consider some sort of connection pooling strategy. Open-use-close is not very efficient when you are accessing the database very frequently. It is more efficient to pool and reuse open connections in this circumstance. One technique that connection pooling libraries use is to test the connection before returning it from the pool. Then if the connection is bad (e.g. timed out by the database) you can throw it away and open a new one. That way, if your application is making lots of database accesses you avoid the overhead of opening and closing connections all the time. When your application idles and does not access the database for a long time, the connection can be dropped and a new one will be opened, "invisibly" from the point of view of the code using the connection.
You don't say what language of framework your application uses, but there are connection pooling libraries available for .NET, Java, Python, Ruby and many others.
|
|
|
|
|
I'm using C++/MFC (stop laughing ). The data base activity is an 'add-on' to a process control application. I'm thinking of moving the data base handling off into a separate thread of its own, so that it can do the open/CRUD/close without affecting the other stuff that's going on.
Software Zen: delete this;
|
|
|
|
|
Instantiate the connection once, but open and close it only as needed.
|
|
|
|