|
Hi Dave,
Cant you retrieve all the Required information for the deleted row before deleting it buy adding a new command before deleting.
For updating the DB you can use the commonDataAdapter Update Command
//Like this
commonDataAdapter.Update(commonDataSet);
and the adapter will update the DB and apply the changes to the DataSet.
That can be of help for you.
Best Regards
Live forever or just live a happy life (You Decide !)
|
|
|
|
|
Hi,
I was thinking that also but what I am confused about is that a DataSet is detached and designed to do this, unlike the Data Reader.
User UI (DataSet)<----> Middle Service Component (DataSet) <----> DataBase
If Microsoft is providing the ability to capture updates to pass to other objects, specifically via a DataSet, it does not make any sense to me that we have to deal with deleted records using a different rule? I understand a DataSet could hold other stuff apart from SQL like XML, Array, and Direct Table etc.
So what we are suggesting here is that the updated DataSet captures all the edits and updates, which can be passed to another component, but we have to deal with deletions manually? Obviously that’s possible but considering
a DataSet can be a complete set of relational tables, e.g. Customer ->> Orders -->Order Lines etc. does this not seem a bit of a task?
I am sure its me being stupid and someone will says its standard functionality but I can't find it?
I will dig about for some articles on this me thinks....
Cheers
Dave
|
|
|
|
|
Hi,
I think I have worked this out now by using a DataView in cobination with a DataSet!
DataSet does indeed operate as expected but we can sync the DataSet up with a DataView and this details the information I wanted regarding ViewRowState, e.g capturing changes that have been made to the DataSet in terms of Deletes, Updates and Additions.
So the DataView provides the sync record information in terms of rowstate between the DataSet such as :-
Added,
CurrentRows,
Deleted,
ModifiedCurrent,
ModifiedOrigional,
OrigionalRows,
Unchanged.
We can also combine these flags so I can get Added, Deleted and ModifiedCurrent.
I have created a sample application that demonstrates and explains if you are interested.
Cheers
Dave
HAL 9000: I'm sorry Dave, I'm afraid I can't do that.
DAVE: What's the problem?
HAL 9000: I think you know what the problem is just as well as I do.
DAVE: What are you talking about, HAL?
HAL 9000: Dave, this conversation can serve no purpose anymore. Goodbye.
|
|
|
|
|
Hi,
I'm not sure how to go about this...
I need to compare ID numbers to achieve two different columns (Size and Category from the same field). If I use UNION I'll get a new row, I just want another column added to the existing columns. Can you have more than one SELECT statement to add more columns to your output? Or am I going about it wrong?
Thanks,
Ron
SELECT Products.ItemNumber, SizesAndCategories.SizeCatName AS Size FROM Products, SizesAndCategories WHERE Products.SizeID=SizesAndCategories.SizeCatID AND Products.ItemID=?
//Join Somehow?
SELECT SizesAndCategories.SizeCatName AS Category FROM Products, SizesAndCategories WHERE Products.CategoryID=SizesAndCategories.SizeCatID AND Products.ItemID=?
|
|
|
|
|
myNameIsRon wrote: Can you have more than one SELECT statement to add more columns to your output? Or am I going about it wrong?
Yes, but from your example I cannot see what you are trying to do.
If this does not work, could you provide some sample data and show how you'd like it all joined up.
SELECT Products.ItemNumber, SizesAndCategories.SizeCatName AS Size, Categories.Category
FROM Products
INNER JOIN SizeAndCategories ON Products.SizeID=SizesAndCategories.SizeCatID
INNER JOIN (SELECT SizesAndCategories.SizeCatName AS Category
FROM Products
INNER JOIN SizeAndCategories ON Products.CategoryID=SizesAndCategories.SizeCatID
WHERE Products.ItemId = @ItemId) AS Categories
WHERE Products.ItemId = @ItemId
By the way, you can probably tell I prefer the explicit use of the JOIN type (e.g. INNER JOIN) to make it very obvious on what conditions two tables are joined together. I happen to think it makes the code easier to understand.
ColinMackay.net
Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?
-- modified at 3:04 Thursday 2nd March, 2006
|
|
|
|
|
Hi Colin,
Thanks for your help. Sorry about not been better at explaining myself (new to sql), also sorry for not using the right sql terms...
Note: I'm using MS Access DB, so I think I only have LEFT and RIGHT JOIN?
Here is what I want to do, maybe JOIN is not the way to go?
In my Table "Products" I have two fields "SizeID" and "CategoryID" that references the SizeCatID in my Table "SizesAndCategories". The SizeCatName could be either a Size Or Category name, so I need a condition each time I pull it.
So basically (in none sql terms):
SizesAndCategories.SizeCatName AS Size (if SizeID = SizeCatID)
SizesAndCategories.SizeCatName AS Category (if CategoryID = SizeCatID)
Maybe renaming the Tables would work (I've seen this a,b used before)?
SELECT a.SizeCatName AS Size, b.SizeCatName AS Category FROM Products, SizesAndCategories a, SizesAndCategories b WHERE Products.SizeID = a.SizeCatID, Products.CategoryID = b.SizeCatID
Thanks for your help!!
Ron
-- modified at 11:34 Friday 3rd March, 2006
|
|
|
|
|
Hi,
I want to create index in my SQL Server database using
ADO.NET. I have a query something like this:
CREATE INDEX <index name="">
ON ( <column name=""> )
The query is correct( i have checked it in SQL Query Analyzer). But i dont know how to execute it using ADO.Net. I have used ExecuteNonQuery of SqlCommand class. But that does not work.
Any suggestion/solution please...
|
|
|
|
|
wasife wrote: I have used ExecuteNonQuery of SqlCommand class. But that does not work.
Too vague. How does it "not work"?
Since you can run just about any SQL through a SqlCommand (including CREATE INDEX) there must be some explanation and saying "that does not work" gives us no idea of where to start helping you.
ColinMackay.net
Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?
|
|
|
|
|
Colin Angus Mackay wrote: saying "that does not work" gives us no idea of where to start helping you
Please give more detail as to what is not working
Paul
|
|
|
|
|
Deat CPians,
I have a heavy duty database on SQL Server 2000.
Every now and then I monitor the transactions applied against the database using SQL Profiler in order to spot the queries and SPs that use alot of CPU resources.
Here are a few of many transactions that my question will be based on:
APPLICATION TEXTDATA DURATION STARTTIME READS WRITES CPU
---------------------------------------------------------------------------------------------------------------------------------------------
.Net SqlClient Data Provider 1229250 1/3/2006 10:53:53 am 2080346 366 60811
Internet Information Services 618203 1/3/2006 10:54:38 am 61550 1 4016
.Net SqlClient Data Provider exec lc_getLatestIpById @mem_id = 267980 483 1/3/2006 11:26:44 am 4594 0 484 As you can see the second column displays the actual querry.
I noticed the there are many requests that have no TEXTDATA at all like the two firsts ones. Not only I do not know what these transactiosn are, but they are very heavy, they cost alot!
What are these transactions? What triggers them?
Thanking you in advance.
theJazzyBrain
Excellence is not an act, but a habit! Aristotle
|
|
|
|
|
Hello All
I have looked into this on the web and found many articals explaining what causes the problem. Some I understand and some I don't but I am no closer to fixing it so some help would be great.
Problem:
I have a table I AM NOT allowed to alter, I can only run select queries against it. The table has a column called docsize (Document Size) in btyes, I run the following query on it.
Select Sum (DocSize) AS myDocSize From Document
Being bytes these are generally "1001374" bytes in size with around 100 000 rows on the table. The resulting number of the SUM is to big I guess so how to I work around this.
P.S. When I get this final figure I bring it in with this Sub
<br />
Private Sub TotalDocumentSize()<br />
Dim Command1 As SqlCommand = New SqlCommand("Select Sum (DocSize) AS myDocSize From Document")<br />
<br />
Command1.CommandType = CommandType.Text<br />
Command1.Connection = SQLConnection1<br />
<br />
Dim myDocSizeVarTmp As Integer = CType(Command1.ExecuteScalar(), Integer)<br />
BytesToMegabytes(myDocSizeVarTmp)<br />
<br />
End Sub<br />
And then run this Function
<br />
Public Function BytesToMegabytes(ByVal Bytes As Double) As Double<br />
'This function gives an estimate to two decimal<br />
'places. For a more precise answer, format to<br />
'more decimal places or just return dblAns<br />
<br />
Dim dblAns As Double<br />
dblAns = (Bytes / 1024) / 1024<br />
BytesToMegabytes = FormatNumber(dblAns, 2, , , TriState.False)<br />
<br />
Dim MyItem As ListViewItem<br />
MyItem = New ListViewItem("Total Document Size (MB)")<br />
MyItem.SubItems.Add(BytesToMegabytes)<br />
listStat.Items.Add(MyItem)<br />
End Function<br />
Any help would be great...
When people make you see red, be thankful your not colour blind.
|
|
|
|
|
You can try:
Select Sum (cast(DocSize as bigint)) AS myDocSize From Document
Wout Louwers
|
|
|
|
|
Also, in your code, try to store it in a UInt64, much bigger.
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
Thanks both your ideas worked the UInt64 gave an error but prompted me to use long for now.
Thanks you Both
"Hummmm what should we call an something bigger than an int 'BIGINT'"
Two SQL developers when home very happy with their decision.
When people make you see red, be thankful your not colour blind.
|
|
|
|
|
Hello,
I'm developing a simple website with a SQL server 2005 back-end. I've designed my database schema and I'm ready to create the database and add tables. So, here's my question:
When building a database backend for a web application, do you generally build the database on a local development machine and then somehow move it to the server? Or do you build it in place on the server somehow (by running server-side sql queries or something)?
I just need a little high-level help here.
Thanks!
-Ian
Ian
|
|
|
|
|
You can generate scripts while creating your schema objects on your local dev machine, modify as needed and then run the scripts against your production machine later. As you make changes you keep this same practice and then you can rebuild the schema whenever you want when you get new development or testing boxes...
hth
Al
|
|
|
|
|
I create scripts. When I'm ready to deploy I run the scripts on the live server.
Once the system is in production and there is an upgrade to do I take a backup of the live (production) system and restore it on the development platform and test the migration scripts. Once they work, I run them on the live server when deploying the changes.
ColinMackay.net
Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?
|
|
|
|
|
Colin Angus Mackay wrote: I create scripts. When I'm ready to deploy I run the scripts on the live server.
Yeah, no sense in risking live production data if something isn't right in the script.
Colin Angus Mackay wrote: Once the system is in production and there is an upgrade to do I take a backup of the live (production) system and restore it on the development platform and test the migration scripts. Once they work, I run them on the live server when deploying the changes.
Good to have your bases covered
PJC
|
|
|
|
|
B"H
Please post links to examples of creating databound multirecord controls in winforms for .net ver 2.
I am looking for something like adding data binding to the listview or creating any control that can display (and even better if it can edit) multiple records at a time and use the standard databinding.
ASP.net seams to be getting all the attention in this area. to the extent that you can now acomplish easily in HTML that which is nearly imposible in a rich windows client.
Thanks
Moshe Plotkin
|
|
|
|
|
I have a table that has a set of financial transactions (simplified version)
Transactions
(
Account varchar(200),
TransactionDate datetime,
TransactionNo int,
TransactionType int,
Value money
)
Transactions can be payments or withdrawals. When a withdrawal takes place this is applied across the payments where the payment number is less than the withdrawal trans and the value of that transaction is reduced.
e.g. if I have transactions:
1, 2005-01-01 , Payment, $100
2, 2005-06-01 , Payment, $150
3, 2005-06-08 , Withdrawal, $180
Then after the third transaction the remaining value in the two payments is
1, 2005-01-01, Payment, $0
2, 2005-06-01, Payment, $70
So now I need to produce a report of the net value of the transactions account at a given date i.e. if the date passed in is less that 2005-06-08 then it would be $100 and $150 otherwise $0 and $70. Is there any clever view / query to do this or will i have to do a cursor?
Thanks in advance
'--8<------------------------
Ex Datis:
Duncan Jones
Merrion Computing Ltd
|
|
|
|
|
I do something similar and use a database procedure that implements two cursors and then calculates and stores in a separate table the results for each payment transaction. Essentially you provide the date to the procedure and the proc opens two cursors, one for all the payment transactions, and another for all the withdrawls. You then loop through each payment transaction one at a time and loop through the withdrawls inside that loop.
Chris Meech
I am Canadian. [heard in a local bar]
When I want privacy, I'll close the bathroom door. [Stan Shannon]
BAD DAY FOR: Friendly competition, as Ford Motor Co. declared the employee parking lot at its truck plant in Dearborn, Mich., off limits to vehicles built by rival companies. Workers have to drive a Ford to work, or park across the street. [CNNMoney.com]
Nice sig! [Tim Deveaux on Matt Newman's sig with a quote from me]
|
|
|
|
|
I am using VB.Net and have recently started working with databases. I hae managed to connect to and manipulate databases done in access that hae already been built, but I am currently trying to use a database I have built but get errors when I try to generate a dataset. The error reads "Retreiving the schema for OleDbDataAdapter1 failed. IErrorInfo.GetDescription failed with E_FAIL(0x80004005)" I think it has something to do with how I am building the database, all I hae done is create a new database and put a table in it with the headings that I require. I wold be greatfull if anyone cold tell me what else I need to do to the database to make it work.
Health Warning! Childlessness is hereditary (If your perents didn't have kids, neither will you!!)
|
|
|
|
|
I'm using SQL Express and I have a table that has a column of type image. My question is how to I go about inserting and/or updating an image in a row using C#? I'm aware that the image type in SQL is simply a BLOB, but I don't know how to insert an acutal picture (.jpg) using C#. Any and all help on this is very appreciated.
- Aaron
|
|
|
|
|
just check this article it helped me. www.codeproject.com/cs/database/ImageSaveInDataBase.asp
I hope it will help u too.
|
|
|
|
|
Hi,
I have put togther a windows 2003 server. I have SQL 2005 running and operating. I am having trouble connecting to my database from outside my network...I have port forwarding on tcp:1433. I have a public ip and domain services routing fine.
any suggestions?
Thanks,
Charles Pence
Student/DOTNET DEVELOPER
|
|
|
|