|
Yes, just change /DataDirectiry|\HV.sdf to be a network path to the file, such as //SMJnr/DataDirectory/etc. Then make sure the file is visible on the network.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
Is there anything additional I need to change for instalation purposes, or does switching that line of code handle those issues itself?
|
|
|
|
|
Sorry, forgot to thank you for your help! Very much appreciated that you take time to help people that have limited knowledge, I appreciate it.
|
|
|
|
|
Thanks in advance
modified 28-Nov-12 8:10am.
|
|
|
|
|
You may want to check out the following tool ...
Beyond Compare
http://www.scootersoftware.com/index.php[^]
You could script the tool to generate a difference report by setting the correct command line switches.
Awesome tool.
|
|
|
|
|
Thanks for link, will checkout.
Is it possible to view the coding of the tool and change according to our requirement?
|
|
|
|
|
Vijay
This is your algorithm reduced to the essentials.
Open OutputFile 'Using sw As StreamWriter
Open InputFile 'Using sa As StreamReader
Copy InputFile to CpyFile 'i.e. to Similar1.txt
Read InputFile into temp '1st header
Set up p() array from temp
Read InputFile into temp '2nd header
While not at end of InputFile
Read InputFile into temp 'Data line
Split temp 'Into name, child, etc
Open CpyFile 'Using sa1 As StreamReader
Read CpyFile into temp1 '1st header
Set up p() array from temp 'Why? This has already been done
Split temp1 'Into name1, child1, etc
Write Name1, child1, etc to OutFile '1st header. Why not just write temp1 without splitting?
Read and Write from CpyFile '2nd header
While not at end of CpyFile
Read CpyFile into temp1 'Data line
If (temp matches temp1) and created < created1 Then
Write temp1 to OutFile
Else
Write temp to OutFile
End If
End While 'not EOF CpyFile
Close CpyFile 'End Using
End While 'not EOF InputFile
Close InputFile 'End Using
Close OutPutFile 'End Using
There are some obvious problems - design not coding.
1. You write the header out each time you open the copy file. It should only be done once when you open the input file.
2. For each data line read from the copy file you write a line to the output file. Think about what happens when you read the first data line in both input and copy files. You cannot decide what to write until you have scanned all of the copy file for a match.
3. The scan of the copy file should begin at the next record after the one read from the input file. E.g. if you read the 10th data line from input file, the scan of copy file should start at 11th data line.
4. You have to open and close the copy file once for each data line in the input file. I don't know how many lines you will have in input file but that could be a lot of I/O.
5. The IF statement will be done once for each data line in copy file. But it's enclosing While loop will be done once for each data line in the input file. So if there are N data lines, it will be done N^2 times. For 10 data lines, that's 100 times; for 100 data lines that's 10,000 times. Performance for small test files might be ok, but large production files could be a problem.
I've not suggested solutions because I think this approach is not the right one. As I said before the solution lies in reading the input file into a list (or an array) and processing that.
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
|
|
|
|
|
Thanks for the reply.
Is there a possible way to handle the if statement?
im not sure where to write the if statement, inside the while loop of the 2nd file or outside the while loop of the 2nd file??
|
|
|
|
|
Moving the IF statement won't achieve a lot. There's a lot more needed to fix the logic than that.
If you post your email address (not usually recommended) I can send you a possible solution - it's a bit big to post here.
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
|
|
|
|
|
|
When you finish scanning the copy file you always need to output a line.
I still think there's a problem not showing up in your test data.
Suppose I have a file where the 5th and 10th lines match with the 10th having a later date. When the 5th line of the input is being processed, it will match the 10th line in the copy and the 10th line will be output. What happens when the 10th line of the input file is being processed? How do you know it's already been written out?
You seem to have introduced a new requirement. Namely, always write out lines that begin with '01' even when there are matching ones.
Try this as a test. Copy first 5 lines of above input, paste them into the file, somewhere in middle of file will do, and change the dates of the pasted lines to e.g. 27/04/2009. Do you get correct output?
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
|
|
|
|
|
Reply for the first paragraph.
What u say is true, few lines may be written More than once.
For that case,Im writting code currently to remove similar lines.
Reply for the second paragraph:
I will not have this condition, because in my previous function before doing the parent-child, i have counted the similar lines and written as quantity field.
so there is no chance of parent starting with "01" to be repeated with diffeent dates.
|
|
|
|
|
It struck me that one way of thinking about this is that, having read an input line, if a match is found with a later date you just need to ignore the input line (the later dated one will be picked up in it's turn); otherwise you can write out the input line. This will do that.
Using sw As StreamWriter = New StreamWriter(oFile, False, System.Text.Encoding.Default)
Using sa As StreamReader = New StreamReader(iFile, System.Text.Encoding.Default)
File.Copy(iFile, "c:\DB\Output1\Similar1.txt", True)
temp = sa.ReadLine()
....
sw.WriteLine(sa.ReadLine())
While sa.Peek() >= 0
temp = sa.ReadLine()
....
If Trim(name).Substring(0, 2) = "01" Then
sw.WriteLine(name & child & desF & desAF & desA & desAA & ecn & dnf & baloon & dateTime & qty)
Else
Dim foundLaterMatch As Boolean = False
Using sa1 As StreamReader = New StreamReader("c:\DB\Output1\Similar1.txt", System.Text.Encoding.Default)
sa1.ReadLine()
sa1.ReadLine()
While (sa1.Peek() >= 0 ) AndAlso (Not foundLaterMatch)
temp1 = sa1.ReadLine()
.....
If name = name1 And child = child1 And dnf = dnf1 And baloon = baloon1 And result < 0 Then
foundLaterMatch = True
End If
End While
End Using
If Not foundLaterMatch Then
sw.WriteLine(currentLine)
End If
End If
End While
End Using
End Using
I've missed out lines that set name etc. and also dropped currentLine.
BTW Did you know that if you change each And in If name = name1 ... to AndAlso it will be slightly more efficient?
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
|
|
|
|
|
hello every one
i am using VS 2005
now i am having mdi form in that i am having 1 toolstrip menu item of backup which has the functionality of backup of my whole database
for that i wrote code like
imports system.io
Directory.CreateDirectory("c:\ backup")
Dim a As String = " c:\myproject\bin\debug\my.mdf"
Dim d As String = "c:\backup\my.mdf"
FileCopy(a, d)
MsgBox("backup Successfully")
but the problem is the directory name backup is created but data base is not copied in it
please help
|
|
|
|
|
I think the problem is
Directory.CreateDirectory("c:\ backup")
Remove the space after "\"
Rajesh B --> A Poor Workman Blames His Tools <--
|
|
|
|
|
hello
i tried by removing space but still it doesnot copy my.mdf file to backup directory
please suggest...
thank you...
|
|
|
|
|
remove space from Dim a As String = " c:\myproject\bin\debug\my.mdf"?
|
|
|
|
|
If Not IO.directory.exists("C:\Backup") Then
IO.Directory.Create("C:\Backup")
End If
Dim a As String = "C:\Myproject\bin\debug\my.mdf"
Dim d As String = "C:\Backup\my.mdf"
IO.File.Copy(a,d)
MsgBox("Backup of 'my.mdf' was succesfull.")
This should do the trick.
Motivation is the key to software development.
|
|
|
|
|
hello
i tried with code you suggested but this is not working...
there is still no copy of my.mdf file is made to Backup folder..
just folder with blank data is created in c drive...
please suggest...
|
|
|
|
|
Does C:\Myproject\bin\debug\my.mdf exist?
Does C:\Backup\my.mdf exist?
|
|
|
|
|
Just curious, are you using Vista? If so, try running your program with Administrator priviliges
Cheers,
Zaegra
Motivation is the key to software development.
|
|
|
|
|
Hello,
do you use your database in your form? You won't be able to copy a open database.
Regards: Didi
|
|
|
|
|
Hi,
Iam using VS.2008 & looking to change programmatically, from Regional language setting [control pannel] date format to dd/MM/yyyy .
Any better ideas?
Thanks Again
|
|
|
|
|
I for one certainly wouldn't want any program to change my PC's regional settings.
Why would you want to programmatically change anything in the regional settings?
Why not just change the date format in your app ?
My advice is free, and you may get what you paid for.
|
|
|
|
|
Changing system-wide settings just to run your app is a VERY VERY VERY BAD idea.
|
|
|
|