|
Hey there,
I have two datasets with exactly the same tables and exactly the same columns. I want to merge the second dataset into the first dataset, but i want to maintain the original row version of the first dataset.
ds1.Merge(ds2, true, MissingSchemaAction.Ignore) only changes the Original Row version of ds1's rows and ds1.Merge(ds2, false, MissingSchemaAction.Ignore) changes both Original AND current value... is there no way to change only the Current version of a row??
I cannot ds2.Merge(ds1) because i have a modified dataset class which inherits datasets but also maintain a connection to a database. ds1 and ds2 are both connected to diffrent databases and changing the connection after merge doesn't work ;-(
|
|
|
|
|
thinking one step beyond solves the problem, which means I've already got a solution...
for this interested, you need two merges...
ds2.merge(ds1, true, MissingSchemaAction.Ignore)
ds1.merge(ds2, false, MissingSchemaAction.Ignore)
|
|
|
|
|
Hi!
I have written my own datatable merge function. It merges 2 datables, adding ew clumns to the source if those dont exists, and also append the new rows to the source. Hope my code is of help to you?
Michiel Erasmus
MaxCredible B.V.
Nieuwezijds Voorburgwal 44
1012 SB Amsterdam
Postbus 11079
1001 GB Amsterdam
Postbus 11079
1001 GB Amsterdam
T: +31(0)20-3449070
F: +31(0)20-3449071
I: http://www.maxcredible.com
<br />
#region MergeDataTables(), merge 2 datatables.<br />
<br />
public DataTable MergeDataTables(DataTable dtInput, DataTable dtOutput)<br />
{<br />
return MergeDataTables(dtInput, dtOutput, false);<br />
}<br />
<br />
public DataTable MergeDataTables(DataTable dtInput, DataTable dtOutput, bool addNewRowsToMerged)<br />
{<br />
if(dtInput == null)<br />
{<br />
return dtOutput;<br />
}<br />
<br />
try<br />
{<br />
if(dtOutput == null)<br />
{<br />
dtOutput = dtInput.Clone();
<br />
if(dtOutput == null)
{<br />
return dtOutput;<br />
}<br />
}<br />
<br />
try<br />
{<br />
foreach(DataColumn dc in dtInput.Columns)<br />
{<br />
if(dtOutput.Columns[dc.ColumnName] == null)<br />
{<br />
dtOutput.Columns.Add(dc.ColumnName, dc.DataType);<br />
}<br />
}<br />
}<br />
catch<br />
{<br />
string strTijdelijk;<br />
strTijdelijk = "dummy";<br />
}<br />
<br />
foreach(DataRow drInput in dtInput.Rows)<br />
{<br />
DataRow drOutput;<br />
<br />
if(dtOutput.Rows.Count == 0 || addNewRowsToMerged)<br />
{<br />
drOutput = dtOutput.NewRow();
}<br />
else<br />
{<br />
drOutput = dtOutput.Rows[0];<br />
}<br />
<br />
drOutput.BeginEdit();<br />
<br />
foreach(DataColumn dcInput in dtInput.Columns)<br />
{<br />
try
{<br />
drOutput[dcInput.ColumnName] = drInput[dcInput.ColumnName];
}<br />
catch<br />
{<br />
string strTijdelijk;<br />
strTijdelijk = "dummy";<br />
}<br />
}<br />
<br />
drOutput.EndEdit();<br />
if(dtOutput.Rows.Count == 0 || addNewRowsToMerged)<br />
{<br />
dtOutput.Rows.Add(drOutput);<br />
}<br />
dtOutput.AcceptChanges();<br />
}<br />
dtOutput.AcceptChanges();<br />
}<br />
catch(Exception ex)<br />
{<br />
throw new Exception(ex.Message + "; Stacktrace=" + ex.StackTrace, ex);<br />
}<br />
<br />
return dtOutput;<br />
}<br />
#endregion<br />
met vriendelijke groet,
Michiel Erasmus
|
|
|
|
|
Ziet er op zich wel OK uit, maar denk dat het niet een oplossing was geweest voor mijn probleem. Ik heb een selectie van data die ik uit de database trek, op een laptop zet en zonder database connectie wijzig. Daana wil ik een sync doen van de data terug naar de db. Ik heb dan twee identieke datasets (qua structuur dan) alleen is de 'sql' dataset gevuld met oude data, en de 'nieuwe' dataset gevuld met de up-to-date data. Ik moet in de 'sql' dataset dan wel de gewijzigde rijden bijhouden (nieuwe, gewijzigde en verwijderde) om aan een adapter door te geven wat hij in mijn db moet wijzigen... moeilijk verhaal allemaal (waarschijnlijk omdat ik het onhandig uitleg) maar vooral door de AcceptChanges kan ik de wijzigingen niet meer terugvinden en ben ik dus alsnog de row states kwijt.. echter, de oplossing was al gevonden middels een dubbele merge..
|
|
|
|
|
When I set a password to my access db.
myCon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db.mdb;Password=password");
myCon->Open();
I get a exception error.
"The workgroup information file is missing or opened exclusively by another user"
..but when I remove it, it open ok. What other param's I need to set in order to open a password protected access db?
|
|
|
|
|
if its the database password and not tied to specific users then try the following connection string
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & sFullPath & ";Mode=ReadWrite;Persist Security Info=False; Jet OLEDB:Database Password=" & sPassword
Where sFullPath is the full path and filename of the db and sPassword is the db password.
Jon
|
|
|
|
|
Guys/Gals,
I've not been able to find a "neat", reliable way to fill a DataTable with the results of a DirectorySearcher. I tried multiple variations of the available DataAdapters that I could find, but none seemed to be "adaptable"... (I made a funny!)
Anyway, I'm trying to stay away from a direct LDAP call to AD, and use the DirectorySearcher/SearchResults. I wouldn't think that it would be too difficult. I'm sure there's some way that the Framework will let me do this.
Your assistance is greatly appreciated...
-Ted
|
|
|
|
|
I am in need of a third party tool for a database import/export.
I need to do these operations from a database (say mysql) to an other one (say ms sql). Can anybody suggest me an other option except MS Enterprise Manager from SQl Serv 2000? It would grately help if that application is a free one (gpl).
Thank you.
I hope you understand...
By the way... visit http://nehe.gamedev.net[^]
|
|
|
|
|
Enterprise Manager won't talk to MySql.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Actualy I managed to make "it talk to mysql" through ODBC adapters.
So my question remains. Can anybody help me?
All I need is a application that can read all the data from a database in a specific server and write it to an other server (like from MS sql 2000 to mysql)
I hope you understand...
By the way... visit http://nehe.gamedev.net[^]
|
|
|
|
|
Hi guys,
I've got a smart client application that allows the user to change, create, or delete data that's stored in an MSDE SQL database. I've rolled my own messaging queue so that the when a client updates lots of data at a time (e.g. deletes 500 rows of data, create 2 rows, update 100 rows), I send a batch message to my server application containing 602 sub-messages describing what happened (in other words, one big message containing all the actual messages describing what happened). This way I only have to go over the network from client to server only 1 time.
All that works great.
My problem is that now that the "delete 500, create 2, update 100" batch message is on the server, I have to call a stored procedure in the database for each message: call RemoveRow stored proc 500 times, call CreateRow 2 times, call UpdateRow 100 times.
Using the ANTS .NET profiler to look at my code, it is apparent that this execution of several hundred stored proc calls is a bottleneck. Is there any way to allow the MSDE database to execute a batch of commands all at once? Or better yet, is there a better way of doing this?
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Conversation With a Muslim
Judah Himango
|
|
|
|
|
Hi all
A database question.
Say for example I have a Suppliers table and a Products table in my database. If theoretically each supplier can supply millions of products what would be the most efficient and convenient?
Having a different Products table for each supplier, or a single Products table holding products of all suppliers. If the first option is better would it not be very tricky querying the data for reports and so on?
Thanks again.
Kobus
|
|
|
|
|
kbalias wrote:
what would be the most efficient and convenient?
That depends on how you are going to use the data. You can split the data by supplier and have a partitioned view to stich it back as if it were one big table - you can then query through the view.
Personally, I would keep it as one supplier table and one products table unless you run into performance problems then do work on eliminating the performance issues. I find that second guessing SQL Server on performance is often counter productive because the usage patterns are often not what was originally envisaged.
My: Blog | Photos
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
I have a column with type datetime in an employee's table. I want to delete the records that older than 3 working days. The problem is I can't use getdate()-3 in where clause because I don't know about the holidays and all.. Can anyone help me out ?
Regards,
Zishan
|
|
|
|
|
|
Can't I use some kind of loop in the SQL
|
|
|
|
|
|
Assuming you have a table called Holidays with the a column containing the date of each holiday you could write a query like this:
DECLARE @days int;
SELECT @days = COUNT(*)+3 FROM Holidays
WHERE HolidayDate <= getdate() AND HolidayDate >= getdate()-3
You can then use the @days variable to count back the number of days. For example:
DELETE FROM MyTable WHERE somedate < getdate-@days
Does this help?
My: Blog | Photos
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
Well.. you're right couldn't do it in SQL without a holidays table. However I did it in my C# program. I selected distinct dates from table ordered by Date Desc. Then I deleted every record with the date from my select query ignoring the first three.. Yes I know its poor performance, but this chunk has to run once every morning so I don't need any major performance here. And I had to do it without A holidays table. Thanks for your help
Regards
Zishan
|
|
|
|
|
1. How to look witch tables are in the database.
2. Is possible to create database with my application. And How?
|
|
|
|
|
I work on several programs that require ordinary users to be able to change settings system wide (specific to the programs). However, Windows security is evolving toward forbiding any of the obvious aproaches to sharing data in this way (such as HKEY_LOCAL_MACHINE, and files in the same directory that the program is installed in) The simplest solution that I've been able to find is to use an MSDE database to store shared settings. However, a database server intended to be used over a network seems to be overkill to me. Does anyone have some ideas for my problem?
Nathan Holt
|
|
|
|
|
MSDE is actually limited in how many network connections it can take, however, it sounds like Access would do what you want. I have deployed MSDE for use on single machines, but I was building a database that Access just wasn't good enough for.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian Graus wrote:
MSDE is actually limited in how many network connections it can take, however, it sounds like Access would do what you want. I have deployed MSDE for use on single machines, but I was building a database that Access just wasn't good enough for.
Thanks. I finally found info yesterday that one is allowed to have shared files in the All Users/Application Data provided that one makes a subdirectory and sets its permisions so that all users can write to them. That makes most of the code I have easily fixable.
Nathan Holt
|
|
|
|
|
Are the effects of DDL events like droping or altering an object stored anywhere in SQL Server 2000? For example, if a stored procedure is altered is there some way of getting this information. The SQL server logs only seem to contain info on database level events (start, stop, backup, dbcc check, etc). Is there something similar that would allow me to find the date modified of a table or when a stored procedure was dropped?
|
|
|
|
|
Hello,
I'm having a little problem with the COUNT function. I have a table with payments for customers (say 42 or 54 each), and each payment is marked as paid whenever the customer comes and pays it.
I want to make a query that gives me all the customers with the number of paid payments (including those customers new for this week). The total number of customers is 328, but if I add the COUNT(*) the resulting table only contains 291, all with 1 or more payments (meaning 37 customers have 0 payments.)
Looking in the web I found that COUNT(column) returns the number of rows in which that column is not NULL . In this case, I'm using COUNT(*) which should return the count of all rows. I'm also using a WHERE clause to limit the counted payments to only those that have been paid. I tried a LEFT JOIN , so that at least the resultset would include the rows, even if the count column is NULL , but it didn't work.
Any ideas?
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|