|
hi dear softdev
i build a database named "Alarms" but this is not important !
please attention !
i want to notify my windows application , not to notify any other objects in sql server!!!! (how can i use triggers to notify an application?)
and both of application and database will run in a local computer
perhaps i have to use "notification service"
but it is hard to implement and distribute it !
is there any other solution ?
pleeeeeeeeeeeeeeaaaaaaaaase help me!
|
|
|
|
|
reza assar wrote: perhaps i have to use "notification service"
That would be the best way, its not difficult if you read up about it. Otherwise all I can suggest is polling for changes
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Hello,
I have been working with VB ADO for some time using Visual Studio 2003 and created several applications connecting to Excel with ADO. However, I have moved to Visual Studio 2008 now and have run into some trouble with the new DatagridView in the latest .NET version. Let me step through the process.
Upon 'Form_Load', I connect to my database, fill the dataset, bind it to my DataGridView in a different Form named, which is publicly defined and created upon startup. I utilize the DataGridView values to populate several text boxes and richtextboxes based upon the data. This is all working great.
The problem came when I tried to create other controls to manipulate this datagridView. The lines I am using to access this are:
Form2.DataGridView1.Item("ColumnName", CurrentRecordRow).Value()
Whenever I try this same line of code through a different subroutine (a button click for example) I get an index out of array error.
Through some troubleshooting, I have managed to discover that the 'RowCount' property of the DataGridView changes to '0' when outside the Form_load subroutine where I populate the DataGridView from the created dataset. (in the FormLoad, the rowcount is 236, when I click a button that shoots a messagebox with the Rowcount again, it says its 0)
This explains the 'index' fatal error generated, but not why the data seems suddenly 'gone' once the form has loaded?
Can anyone make a recommendation of what I may be doing wrong in accessing the data within this DataGridView?
thanks,
Grollub
modified on Thursday, October 8, 2009 3:35 PM
|
|
|
|
|
1 Excel is NOT a database and should not be used as a database. I recommend that you change to either XML files for VERY small volumes or SQL Server/Express for more robust data storage. Take Excel out of the design.
2 When manipulating the data in a datagridview you work with the underlying data container (datatable probably)
3 Check the CurrentRecordRow using a break point, it is probably not set
|
|
|
|
|
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!
|
|
|
|