|
Hi guys,
Im getting this error :
Min (110) must be less than or equal to max (-1) in a Range object.
when doing some operations on my datatable
System.ArgumentException: Min (110) must be less than or equal to max (-1) in a Range object.
at System.Data.Select.GetBinaryFilteredRecords()
at System.Data.Select.SelectRows()
at System.Data.DataTable.Select(String filterExpression, String sort, DataViewRowState recordStates)
at System.Data.DataTable.Compute(String expression, String filter)
Here is my code:
for (int i = 0; i < list.Count; i++)
{
lt.Add(list[i].ToString()); -------this is the line that causes the error???
maxObject = dtPar.Compute("MAX(Act_doorlooptijd)", "bijelkaar =" + list[i].ToString());
ls.Add(maxObject.ToString());
}
Any idea's what is wrong here?
Thanks
|
|
|
|
|
Hi,
your message isn't clear.
What is lt , you should show its declaration.
What is list[] , you should show its declaration.
Your exception's stacktrace seems to show .NET class and method names without line numbers, rather than your cladd and method names with line numbers.
You should debug in debug build, not in release build; that way you get line numbers.
You should also tell your IDE (Visual Studio?) to show line numbers in all editor windows, so you can match the exception to the line where it occurs. I doubt it is where you indicated.
ArgumentException is what you often get when you pass inacceptable values to a .NET method or property, say the Minimum, Value and Maximum properties of a scrollbar.
Could it be list[] is somehow set as the DataSource to lt, whatever that is?
that is the only way I can imagine the statement you indicate causes those .NET methods to execute.
And please show code using the "code block" button, which adds PRE tags, a background color, a monospaced font, and preserves formatting.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Just got through the same issue. Just add single quotes around the value:
maxObject = dtPar.Compute("MAX(Act_doorlooptijd)", "bijelkaar ='" + list[i].ToString()+"'");
|
|
|
|
|
i want to compare two .dat file.One .dat file contains lines of file name with it record count and size.
MRR_GIQ_FR_X03_M0808_GIQDTL_GIQDTLCTCT.dat~612~3~
MRR_GIQ_FR_X03_M0808_GIQDTL_GIQDTLDETL.dat~1036~3~
MRR_GIQ_FR_X03_M0808_GIQDTL_GIQDTLMTG.dat~875~3~
We need to write a code to compare each .dat file with .dat file.
when record count and size differ it must exit,else continue with next file.
my code is
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.IO.Compression;
namespace ConsoleApplication1
{
class Class1
{
public bool splitFile = false;
static void Main(string[] args)
{
CompareFiles();
}
//Compare 2 files
public static void CompareFiles()
{
string srcFile = "C:\\SampleFile\\MRR_GIQ_FR_X03_M0808_GIQDTL_GIQDTLCTCT.dat";
string destFile = "C:\\SampleFile\\MRR_GIQ_FR_X03_M0808_STATS.dat";
if (Class1.FileCompare(srcFile,destFile))
{
Console.Write("Files are equal.");
}
else
{
Console.Write("Files are not equal.");
}
}
private static bool FileCompare(string file1, string file2)
{
int file1byte;
int file2byte;
FileStream fs1;
FileStream fs2;
// Determine if the same file was referenced two times.
if (file1 == file2)
{
// Return true to indicate that the files are the same.
return true;
}
// Open the two files.
fs1 = new FileStream(file1, FileMode.Open);
fs2 = new FileStream(file2, FileMode.Open);
// Check the file sizes. If they are not the same, the files
// are not the same.
if (fs1.Length != fs2.Length)
{
I NEED THE CODE HERE TO COMPARE THESE TWO DAT FILE
}
// Read and compare a byte from each file until either a
// non-matching set of bytes is found or until the end of
// file1 is reached.
do
{
// Read one byte from each file.
file1byte = fs1.ReadByte();
file2byte = fs2.ReadByte();
}
while ((file1byte == file2byte) && (file1byte != -1));
// Close the files.
fs1.Close();
fs2.Close();
// Return the success of the comparison. "file1byte" is
// equal to "file2byte" at this point only if the files are
// the same.
return ((file1byte - file2byte) == 0);
}
PLEASE HELP WITH CODE OR ANY USEFUL LINKS.........
|
|
|
|
|
Hi,
That is a lot of code already, without much being achieved.
You do not really have to test for identical files, same length, etc; if the data comparison is present and correct, that would generate the right result anyway; checking for identical files and same length, are optimisations that initially will make your testing more difficult. I suggest you concentrate on the heart of the matter first.
You probably don't need FileStreams at all.
Assuming both files are text files, you could use File.ReadAllLines() twice, then sort both arrays, and compare the two arrays.
Assuming the lines are in a fixed order (maybe the filenames are ordered alphabetically) you could even just use File.ReadAllText().
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
how to create a set up file for a project
|
|
|
|
|
You can create a new setup project in VS 2005.
Include the project you would like to create a setup file for. Add the dlls to dependency and then Build it.
|
|
|
|
|
- right click on your newly created setup project
- go to View -> File System
- you'll see a new opened window
- right click on Application Folder -> Add -> Project Output
- select the project and Primary Output
Calin
|
|
|
|
|
You can also use Inno Setup here[^]. It's a free installer for Windows programs with nice feature set and good stability.
|
|
|
|
|
Dear All,
I have an application which is reading a datagram from the client.
If the bytes to be read is greater that are equal to the byte sent, then it is working fine.
But my requirement is to read the data by 10 bytes at a time or specific bytes configured by the user.
I don't know how to achieve this.
The code used is:
private void OnReceive(IAsyncResult ar)
{
try
{
IPEndPoint ipeSender = new IPEndPoint(IPAddress.Any, 0);
EndPoint epSender = (EndPoint)ipeSender;
int aCount = serverSocket.EndReceive(ar);
Data msgReceived = new Data(byteData);
string aReadData = System.Text.ASCIIEncoding.ASCII.GetString(byteData, 0, aCount);
int aPacketEnd = aReadData.LastIndexOf("|");
if (aPacketEnd == -1)
{
aPacketEnd = aReadData.LastIndexOf('\0');
}
if (aPacketEnd != -1)
{
string aValidData = System.String.Empty;
string aPacketData = System.String.Empty;
if (myBuffer.Length > 0)
{
aValidData = System.Text.ASCIIEncoding.ASCII.GetString(myBuffer);
}
if (aPacketEnd < aCount - 1)
{
myBuffer = new byte[aCount - (aPacketEnd + 1)];
System.Buffer.BlockCopy(byteData, aPacketEnd + 1, myBuffer, 0, aCount - (aPacketEnd + 1));
}
else
{
myBuffer = new byte[0];
}
System.Threading.Thread.Sleep(100);
byte[] message = new byte[10];
serverSocket.BeginSendTo(message, 0, message.Length, SocketFlags.None, epSender,
new AsyncCallback(OnSend), epSender);
byte []byteData = new byte[10];
serverSocket.BeginReceiveFrom(byteData , 0, byteData.Length, SocketFlags.None, ref epSender,
new AsyncCallback(OnReceive), epSender);
}
else
{
byte[] aTempArray = new byte[myBuffer.Length];
System.Buffer.BlockCopy(myBuffer, 0, aTempArray, 0, myBuffer.Length);
myBuffer = new byte[aTempArray.Length + (aCount)];
System.Buffer.BlockCopy(aTempArray, 0, myBuffer, 0, aTempArray.Length);
System.Buffer.BlockCopy(byteData, 0, myBuffer, aTempArray.Length, aCount);
byteData = new byte[0];
byteData = new byte[10];
serverSocket.BeginReceiveFrom(byteData, 0, byteData.Length, SocketFlags.None, ref epSender,
new AsyncCallback(OnReceive), epSender);
}
}
catch (Exception ex)
{
IPEndPoint ipeSender = new IPEndPoint(IPAddress.Any, 0);
EndPoint epSender = (IPEndPoint)ipeSender;
byteData = new byte[10];
serverSocket.BeginReceiveFrom(byteData, 0, byteData.Length, SocketFlags.None, ref epSender,
new AsyncCallback(OnReceive), epSender);
}
}
As the datagram sent may be very larger too, so that time I have to limit my reading.
Another important point is to send an ACK when the data transfer is completed. The start and end of the transmission is identified by the character "|".
Can any one help me to get rid of this?
Thanks a lot in advance.
Best Regards,
M. J. Jaya Chitra
modified on Thursday, February 19, 2009 6:58 AM
|
|
|
|
|
Hello,
How can I read a line in PDF, a specific emplacement (ex a square) is in this square you read the line of characters line by line, thank you very much.
|
|
|
|
|
|
I don't find how we read from file pdf, thank you verry mutch
|
|
|
|
|
Have you actually followed the links, read the articles and tried any of it? The second link seems to present a way.
|
|
|
|
|
Hi folks,
Is there any weatherforecating service come with webservice at free of cast? if you know please help me. Mainly that webservice should not change its resultset format frequently.
friendly,
ranandbe
|
|
|
|
|
|
Hello,
I used to use 3rd party installer (wizard based) for my applications and today I was interested to study the Visual Studio Setup Project so that I can use my C# skill to build install time Dialogs, Forms , etc and so on. But when I started learning the Setup Project, I found it is just another kind of advanced Wizard but nothing else. I cannot add Windows Forms, run C# codes. Although I found how to add dialogs and those dialogs are prebuilt, I can just change some values. So, my question is, Why it is like this ? Am I missing something ? Is it not possible for a C# developer to build the installer by his own way using his own Windows Forms, etc ? May be it is possible, but then I will have to create another stand along Windows Application which will be the installer but not using Setup Projects, right ?
Please advice.
Regards
Emran
|
|
|
|
|
It is possible to customize the installer. You may edit the dialogs, add registry keys, deployment files, and most important, custom actions. You need to extend the Installer and override some methods like: Install, OnCommitting, Rollback...so, you may add your C# code here.
Also, in these custom actions you may use the input values from the dialogs fields.
For more customizations related to UI dialogs, use Orca application, which let's you edit the resulted MSI.
Calin
|
|
|
|
|
Also have look at this articles part1[^] and part2[^]. Especially part2 shows some cool customization methods.
|
|
|
|
|
hello all.
m working on windows application uses web services to insert and retreave data
what m trying to do when the application call web service a thread splash screen appear , i did it fine but sometime i get unhandeled exception : "Thread was being aborted" how can i overcome this problime ?
thanks in advance
My Code:
Users user = new Users();//web service
LoadingIndicator.ShowLoading();
int employeeId = user.Login(userName, passWord);
LoadingIndicator.HideLoading();
class LoadingIndicator
{
static Thread LoadingThread;
public static void ShowLoading()
{
LoadingThread = new Thread(new ThreadStart(DoShowSplash));
LoadingThread.Start();
}
public static void HideLoading()
{
try
{
if (LoadingThread.IsAlive)
LoadingThread.Abort();
}
catch (ThreadAbortException ex)
{
Thread.ResetAbort();
}
}
private static void DoShowSplash()
{
frmLoading frm = new frmLoading();
frm.ShowDialog();
}
}
|
|
|
|
|
I am working a desktop application ,in which i using web control and fill auto user id and password and it is filled .so i want to auto Login. please give me a idea how i click event fire .eg www.mail.yahoo.com
Usewrid=abc
password=***
Sign In (button)
adilkhan
|
|
|
|
|
but yahoo already has a feature to keep the user signed in, so you dont need to logon each time...
If only MySelf.Visible was more than just a getter...
A person can produce over 5 times there own body weight in excrement each year... please re-read your questions before posting
|
|
|
|
|
actually there is a web control .i also got this in this site.
http://www.codeproject.com/KB/recipes/Automatic_Login.aspx
adilkhan
|
|
|
|
|
Hi,
Currently i am developing a client server application in c#. I am using socket for communication. With compare to remoting and WCF, is it socket is better?.. or which is good. How can i convert socket to WCF or Remoting?
Thankyou,
Yesuprakash
|
|
|
|
|
It really depends on the situation. I have never used WCF, but sockets is semi-hard to use, but is the fastest and lowest bandwidth, but you do all the work codewise. Remoting packages it up and opens it back up for you, but has lots of overhead with the XML stuff and conversions...
Remoting can be perfectly acceptable is MANY applications, but time-critical packets like those for a video game need faster than remoting provides.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|