|
hmmm... First of all I should say "next time try the SQL\ADO\ADO.NET forum", they know SQL queries better...
Butttt... I can help here (I think).
Second of all, If it's a DateTimePicker it's not Text, it's Value (Properties).
Third of all, in SQL queries ' does NOT stand for DATE!!! # <- this stand for Date! try switching them in the right places. this should work now.
And 4th of all, the # will convert them, don't forget to put in the start AND in the end... i.e: and startdate >='" + txtstartdate.Text + "' -> and startdate >= #" + txtstartdate.Text + "#
Good Luck...
NaNg
|
|
|
|
|
NaNg15241 wrote: Third of all, in SQL queries ' does NOT stand for DATE!!!
Yes, it does. Exclamation mark. The SQL standard uses apostrophes around dates. Exclamation mark. Exclamation mark. Exclamation mark. Exclamation mark. Exclamation mark. Exclamation mark.
The exception is the Access database, that uses the # character instead.
NaNg15241 wrote: And 4th of all, the # will convert them, don't forget to put in the start AND in the end... i.e: and startdate >='" + txtstartdate.Text + "' -> and startdate >= #" + txtstartdate.Text + "#
Do you really expect anyone who doesn't already know what the problem is to understand that?
---
b { font-weight: normal; }
|
|
|
|
|
Not sure, but I think the problem is at the beginning of your where clause:
where case>='" + txtcasestart.Text + "' AND case<='" + txtcasefinish.Text
Anyway, I think you should also take a look at this article: SQL Injection Attacks and Some Tips on How to Prevent Them[^]
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
www.troschuetz.de
|
|
|
|
|
OleDbDataAdapter adp10 = new OleDbDataAdapter("Select case,dailycase From caseinfo where case>='" + txtcasestart.Text + "', and case<='" + txtcasefinish.Text + "' and startdate >='" + txtstartdate.Text + "' and enddate <='" + txtenddate.Text + "'", conn);
|
|
|
|
|
Hi all,
Sorry Code project. I'm posting yet another question. I just cant get past this problem...
I'm trying to get this command executed in cmd through C#.
The command needs to be in Quotation marks like this when it gets sent to cmd...
"c:\Program files\progressive projects\progress\reporttemplates\fop.bat" -xml "c:\program files\progressive projects\progress\reporttemplates\ClientRecordCard.xml" -xsl "c:\Program files\progressive projects\progress\reporttemplates\ClientRecordCardHairFo-pdf.xsl" -pdf "c:\Reports\ClientRecordCard.pdf"
my code looks like this
The TempPath And TempName
TempPath = c:\program files\progressive projects\progress\reporttemplates
TempName = ClientRecordCardHairFo-Pdf
startInfo.Arguments = "/C " + "\"" + @Convert.ToString(TempPath) + "\\fop.bat" + "\"" + " -xml" + "\"" + @Convert.ToString(TempPath) + "\\ClientRecordCard.xml" + "\"" + " -xsl" + "\"" + @Convert.ToString(TempPath) + "\\" + @Convert.ToString(TempName) + ".xsl" + "\"" + " -pdf" + "\"" + @Convert.ToString(Salon.Library.GlobalVariables.Reports_Path) + "\\ClientRecordCard.pdf" + "\"";
my logic tells me that it should work but i get an error saying "'c:\Program' not recognized as an internal or external command, operable program or batch file.
He who laughs last...
|
|
|
|
|
it is as if the Quotes aren't in the right place in my code...
not opening and closing on the right places if you understand what i mean.
He who laughs last...
|
|
|
|
|
You are corecct!!! (Ding Ding Ding Ding Ding!!!) I fixed your qouts in my post here.
|
|
|
|
|
well as I see you don't leave spaces and don't put everything in it's place... (and there are alot of things that could be shorten...)
try this:
startInfo.Arguments = "\"" + @Convert.ToString(TempPath) + "\\fop.bat\" -xml \"" + @Convert.ToString(TempPath) + "\\ClientRecordCard.xml\" -xsl \"" + @Convert.ToString(TempPath) + "\\" + @Convert.ToString(TempName) + ".xsl\" -pdf \"" + @Convert.ToString(Salon.Library.GlobalVariables.Reports_Path) + "\\ClientRecordCard.pdf\"";
this SHOULD work, but I don't promis you cuz I don't realy know what you after here.
NaNg.
|
|
|
|
|
thank you, ill give it a go.
He who laughs last...
|
|
|
|
|
|
hi,
sorry, it didn't work
public void shellControl2()
{
if(CustCd != "")
{
ProcessStartInfo startInfo = new ProcessStartInfo("cmd.exe");
// /c switch sends a command
startInfo.Arguments = "/C " + "\"" + @Convert.ToString(TempPath) + "\\fop.bat\" -xml \"" + @Convert.ToString(TempPath) + "\\ClientRecordCard.xml\" -xsl \"" + @Convert.ToString(TempPath) + "\\" + @Convert.ToString(TempName) + ".xsl\" -pdf \"" + @Convert.ToString(Salon.Library.GlobalVariables.Reports_Path) + "\\ClientRecordCard.pdf\"";
// redirect messages to this program
startInfo.RedirectStandardError = true;
startInfo.RedirectStandardOutput = true;
//don't execute using shellexecute API
startInfo.UseShellExecute = false;
//Don't open command prompt window
startInfo.CreateNoWindow = true;
System.Diagnostics.Process p = System.Diagnostics.Process.Start(startInfo);
string output = p.StandardOutput.ReadToEnd();
string error = p.StandardError.ReadToEnd();
p.WaitForExit();
if (output.Length != 0)
{MessageBox.Show(Convert.ToString(output));
shellControl1.WriteText(output);}
else if (error.Length != 0)
{MessageBox.Show(Convert.ToString(error));
shellControl1.WriteText(error);}
}
}
This is the code snippit i'm using to send a command to command prompt to run the fop batch file to create a pdf file from xml and xsl files. if you can help it would be great. i had it working fine when all the files were in "C:\Reports\" But we had to move it to the derectory where the user installs the program and only the pdf file(Result) would be stored in the "C:\Reports\" directory.
He who laughs last...
-- modified at 9:09 Tuesday 30th May, 2006
|
|
|
|
|
Is this the code? you didn't change anything in here except putting all I've written to you in a variable that probably shows you a warning "command is never used"...
put it in the Argument, it is still the last one that doesn't work.
|
|
|
|
|
the argument is your code. the command variable was my code but i've taken it out
it gives the same error: "'C:\Program' is not recognized as an internal or external command, operable program or batch file."
He who laughs last...
|
|
|
|
|
May I ask what is the /C?
|
|
|
|
|
the /c is the command line switch that lets command prompt know to run the command. That is how i understand it.
He who laughs last...
|
|
|
|
|
Well maybe try without it?
Maybe it's \c and not /c?
Check some stuff out...
Are you sure it's with a space after it? try also that.
-- modified at 9:24 Tuesday 30th May, 2006
|
|
|
|
|
thanks for your time and thanks for trying.
Enjoy your day
He who laughs last...
|
|
|
|
|
No problems... but does it work or not?
|
|
|
|
|
not yet but ill let you know as soon as i get it right. There is something id like to try. but im not prommising anything yet. hold your thums
He who laughs last...
|
|
|
|
|
i've got it Thank you soooooooo much. All we needed was one more "\"" in the beginning of the code it should look like this:
startInfo.Arguments = "/C" + "\"" + "\"" + @Convert.ToString(TempPath) + "\\fop.bat\" -xml \"" + @Convert.ToString(TempPath) + "\\ClientRecordCard.xml\" -xsl \"" + @Convert.ToString(TempPath) + "\\" + @Convert.ToString(TempName) + ".xsl\" -pdf \"" + @Convert.ToString(Salon.Library.GlobalVariables.Reports_Path) + "\\ClientRecordCard.pdf\"";
The Bold part is the extra i was talking about.
THANK YOU! i've been strugling with this since last week Monday. Now i can sleep soundly.
He who laughs last...
|
|
|
|
|
When trying to construct a long string like this, it's much easier to troubleshoot if you start with a single substring and add mroe one at a time after checking the last one works as intented, by printing ot the console.
|
|
|
|
|
thanks for taking the time to try and help me. i've found the problem.
He who laughs last...
|
|
|
|
|
Hey
So I have a XML with DataSet in it, in the DataSet I have 2 DataTables, in each DataTable I have a Unique ID, and I did to this row, auto-inc, and don't allow DBNull, and it's readonly.
So when I try to do NewRow(), and add it without setting the ID column, it throws an Exception DataColumn 'ID' can't allow DBNull.
So how can I do it as UNIQUE ID? do I need to allow DBNull?
Thanks in advanced...
NaNg.
|
|
|
|
|
Hi,
I have hundrets of applications in excel from which I get data from c# - it works.. but some people changed the original pattern of the excel file (for example they merged some cells).. What to do? Is there eny posobility to compary only cells addresses?
Please give me some code maybe - the case is extremally urgent and I didn't know that people would change these documents for their needs....
|
|
|
|
|
No ideas ?
|
|
|
|