|
Hi.
I want to compare two arraylists with each other, but not with the compare method.
That means, I have two computers with an arraylist on each of them. If the contents of these arraylists are the same, the calculated value from the arraylist should also be the same.
So is it possible to compare collections this way? MD5? Hash value? Checksum? Whatever!
Thanks alot 
|
|
|
|
|
lvq684 wrote: So is it possible to compare collections this way? MD5? Hash value? Checksum? Whatever!
Not really; these values are used to check whether the original data has been changed or corrupted in any way. However, they are not universally unique, so if two sets of data generate the same hash code, that does not guarantee that their contents are identical. The only way to compare two sets is to compare each item within the set.
|
|
|
|
|
Well the problem is that i am using .net remoting, and i gotta keep a clients arraylist updated. And it would be a waste of bandwith to send the arraylist as an object over to the server to compare it.
Are there any easier way around this problem then? 
|
|
|
|
|
lvq684 wrote: Are there any easier way around this problem then?
Sorry, not that I know of. Does Google have any suggestions?
|
|
|
|
|
Richard MacCutchan wrote: Sorry, not that I know of. Does Google have any suggestions?
Ive been searching for quite some time now, but with no luck. Thought i might used the wrong keywords, so thats why i posted in here 
|
|
|
|
|
Off Topic : As you mention 'bandwith' I assume that the server and clients are connected via internet. So, I'm just wondering that how your server working, do it needs to open a port ?
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
There is no general solution without comparing it all.
Tell us more, there is bound to be a good solution for a specific case.
What is the application? Is it only two arraylists? do they start off by being identical? how do they evolve? are things removed/modified/added? both sides? how frequent?
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!
|
|
|
|
|
Luc Pattyn wrote:
Tell us more, there is bound to be a good solution for a specific case.
What is the application? Is it only two arraylists? do they start off by being identical? how do they evolve? are things removed/modified/added? both sides? how frequent?
The application is one server and many clients. The server will start off by sending the clients a copy of the newly created arraylist/collection. From time to time, the server will remove/add items (probably strings) from the arraylist, and the clients will afterwards have to fetch the updated arraylist (or the updates?). I am using remoting, so i can pass objects between client and server. But instead of sending the client´s arraylist to compare it (would be a large data transfer if the array is big), i would like to calculate some kind of value based on the list´s content, so i can pass that value to the server and compare it that way.
Unless there are a better solution?
The comparison would probably be once every 5 seconds on each client (around 40 clients).
Thank you for your time! 
|
|
|
|
|
OK, so it seems to be a single producer multi-consumer situation.
This is what I would do:
- on the server create a class that holds the collection (ArrayList, generic List, whatever), and organizes a version number; every addition/removal/modification in the collection should increment the version number; that is why you need your own class, so nothing can change the collection without affecting the version number.
- on each client, whenever relevant, ask the server for its version number and compare with the local version number; when different, go fetch the latest copy of the collection
Possible refinement, depends on the frequency and multiplicity of the changes:
- on the server, keep a list of changes to go from version N to N+1
- on the client, when the versions don't match, ask the differences from local version to official version, and apply them one by one.
Alternative refinement:
- split the collection in smaller collections, give them each a version number, and go fetch the smaller collection you need when it is outdated.
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!
|
|
|
|
|
Thanks for the great reply.
Versioning, of corse! Why the ... didnt i think of that to start with!
Thanks alot Luc 
|
|
|
|
|
My Objective:
Connect to the odbc datasource and recreate it's database, tables, table's fields, and port the data from the Database A (ODBC)to Batabase B (SQL SERVER). Database B being a Microsoft SQL Server 2008 Database.
Here Is what I have:
ODBC connection to a datasource.
What I know how to do is:
Connect to SQL Server to it's master database.
I can check to see if a database with a given name already exists. Including tables, stored procedures, and views.
I can read and write to an existing database.
------------------------------------------------------------------------------
- What I am looking for direction on is: -
- How do I query a existing database for it's set of tables. -
- Also how to query each set of tables for it's fields and field types. -
------------------------------------------------------------------------------
Because I need to reconstruct the database and it' tables in the sql server database, and I will not know it's layout.
To give an example I have a quickbooks, access, and cobol database, and a odbc connection to the databases. All of which need ported to sql server and updated on a specific time frame. I could do this manually, but I wanted to build a service to do this for me. In order to build the service I need to know how to query a database for it's layout and recreate it in the sql server database system.
Can someone please help? Any Ideas or websites that could aid me in understanding how to do this. I will post back also if I find some.
|
|
|
|
|
Download the SQL Server 2008 Samples here[^], and extract them.
Investigate the code samples in the Samples\Engine folder, particularly the Administration, Data Access and Programmability folders.
There are examples of how to do most of the things that you require.
Access has its own tool to upscale to SQL server, if you have acess to Access.
I'm not sure that you can change the database for QuickBooks.
I do not know of a tool to create an SQL Server database from a Cobol database.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I hope that the following article will help you....
A simple example of SQL server admin tools
Thanks
Md. Marufuzzaman
Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you.
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
I have been researching. So far I have come across.
--select * from sys.dm_exec_connections
select * from sysobjects where [name] like 'dbo.%'
select * from INFORMATION_SCHEMA.TABLES
select table_name as Name from INFORMATION_SCHEMA.Tables where TABLE_TYPE = 'BASE TABLE'
SELECT * FROM INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = 'tblprweekendingdates'
in sql server studio manager. Would it be true to sql I can pass these sql statements to a given database via a odbc connection and return the same results?
|
|
|
|
|
when you using odbc as connection source then there are some security issue you must concern..for example
you are connected with database "A" the you cannot fully access to other database if you are not authorized...
You need to check that your loginID is authorized or not to perform transact-sql statement execution to the desire one using odbc.
Thanks
Md. Marufuzzaman
Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you.
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
Access will be pretty simple, I will be astonished if Quickbooks publish their schema or allow you to query their system tables.
As for cobol I'm not sure cobol even has the metadata to query!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi.
I have problems..when i send string from client to server, server recieves string and sends it back to client. Works fine for first time. But now i don't know why i can't send it again, lets say different..
Here is code for server:
public server()
{
InitializeComponent();
}
private void server_Load(object sender, EventArgs e)
{
IPAddress ipAd = IPAddress.Parse("127.0.0.1");
TcpListener myList = new TcpListener(ipAd, int.Parse("1111"));
myList.Start();
try
{
Socket socketForClient = myList.AcceptSocket();
Console.WriteLine("Odjemalec povezan " + socketForClient.RemoteEndPoint.ToString());
NetworkStream networkStream = new NetworkStream(socketForClient);
StreamWriter streamWriter = new StreamWriter(networkStream);
StreamReader streamReader = new StreamReader(networkStream);
line = streamReader.ReadLine();
Console.WriteLine("Sprejeto: " + line);
textBox1.Text = line;
streamWriter.WriteLine(line);
Console.WriteLine("Poslano: " + line);
streamWriter.Flush();
Console.WriteLine();
}
catch (Exception x)
{
Console.WriteLine("Error..... " + x.StackTrace);
}
}
Here is code for my server
private string _ip = String.Empty;
private string _port = String.Empty;
private int izbira;
string novo;
TcpClient odjemalec = new TcpClient();
public client(string ip, string port)
{
InitializeComponent();
this._ip = ip;
this._port = port;
}
private void client_Load(object sender, EventArgs e)
{
try
{
IPAddress novip = IPAddress.Parse(_ip);
Console.WriteLine("Povezujem ...");
odjemalec.Connect(novip, int.Parse(_port));
Console.WriteLine("Povezan");
Console.Write("Vpiši besedilo: ");
String line = Console.ReadLine();
}
catch (Exception x)
{
Console.WriteLine("Napaka: " + x.Message);
}
}
private void poslji()
{
if (comboBox1.SelectedIndex == 0) novo = "1";
if (comboBox1.SelectedIndex == 1) novo="2";
NetworkStream networkStream = odjemalec.GetStream();
StreamReader streamReader = new StreamReader(networkStream);
StreamWriter streamWriter = new StreamWriter(networkStream);
streamWriter.WriteLine(novo);
Console.WriteLine("Pošiljam sporočilo...");
streamWriter.Flush();
string s = streamReader.ReadLine();
textBox1.Text = s;
Console.WriteLine("Prejemam sporočilo...");
Console.WriteLine(s);
}
string textbox()
{
novo = textBox1.Text;
return novo;
}
private void button1_Click(object sender, EventArgs e)
{
poslji();
}
Please help me that i would be able to send more than one time.
|
|
|
|
|
The same question, over and over.
I told you before, store your connection stuff in class members, not local variables, keep them open, reuse them.
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!
|
|
|
|
|
Yeah but i don't know how you mean this..DO i have to make class just for streaming...or for starting tcplistener and client or can i make everything in one class?
|
|
|
|
|
you only need to create one class, it should contain about half of the code you have shown. Typically:
- an open method
- one or multiple use methods (read, write)
- a close method
Do you know how to work with files? it is basically the same.
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!
|
|
|
|
|
Ok..i made new class for most of the code.. now i get error when i try to start streaming client.. here i have code in that class:
public void start_client()
{
IPAddress novip = IPAddress.Parse(_ip);
Console.WriteLine("Povezujem ...");
odjemalec.Connect(novip, int.Parse(_port));
Console.WriteLine("Povezan");
}
public void streamaj_client()
{
NetworkStream networkStream = odjemalec.GetStream();
StreamReader streamReader = new StreamReader(networkStream);
StreamWriter streamWriter = new StreamWriter(networkStream);
streamWriter.WriteLine(podatki);
Console.WriteLine("Pošiljam sporočilo...");
streamWriter.Flush();
string s = streamReader.ReadLine();
Console.WriteLine("Prejemam sporočilo...");
Console.WriteLine(s);
}
here are two methods..i get error at NetworkStream networkStream=odjemalec.GetStream(); It says networkStream=null? But i have connected client to server and it says in console that is connected. What am i doing wrong now?
|
|
|
|
|
|
Why you post this type of queries in this forums....
Thanks
Md. Marufuzzaman
Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you.
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
Hi people
I've got a rather simple question. In my app, I want to 100 by a certain number, and then store the result in a double, or other suitable variable. Lets say I want to say 100/48, the result is 2.0833333. When I try this though, the result always gets rounded off to the nearest decimal. So the result in my app would return 2.0 How can I get it to store 2.083 instead?
|
|
|
|
|
The result of integer division is always an integer; if you want a real (i.e. float or double) result, make sure at least one of the operands is real; for constants, append ".0" to the number, for variables use a float/double variable, or cast to float or double. Examples:
100.0/48
100/48.0
100/(double)INT48
((double)INT100)/48
DOUBLE100/48
100/DOUBLE48
Then optionally use formatting to get the number of decimals you want, as in x.ToString("N3"); or x.ToString("F3");
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!
|
|
|
|