|
I've used sql command here is my code
string CommandText = "select * from par where Time between '" + textBox7.Text + "%' and '" + textBox13.Text + "%' and Date like '" + textBox6.Text + "%' and Linein like'" + textBox8.Text + "%' and Lineout like '" + textBox9.Text + "%'and Duration >= " + textBox10.Text + " ;";
DB = new SQLiteDataAdapter(CommandText, sql_con);
DS.Reset();
DB.Fill(DS);
DT = DS.Tables[0];
dataGridView1.DataSource = DT;
int rowCount = ((DataTable)this.dataGridView1.DataSource).Rows.Count;
textBox12.Text = rowCount.ToString();
sql_con.Close();
It has problem that if I haven't insert value to Time it will not show anything but
if I take the value to it I can run the search and It'll take the value to mydatagrid
|
|
|
|
|
What do you want it to do? ie. when no time or date is entered.
You don't have any validation here at all do you? That's a concern. They could type anything into those textboxes. Wrong input could throw an exception and malicious input could wreck your database. I'd consider parameterising your query rather than string building it.
Regards,
Rob Philpott.
|
|
|
|
|
I want to search it but if I didn't insert value in textBox7 or textBox13 it will not show anything( but I 've inserted data in another textbox)
string CommandText = "select * from par where Time between '" + textBox7.Text + "%' and '" + textBox13.Text + "%' and Date like '" + textBox6.Text + "%' and Linein like'" + textBox8.Text + "%' and Lineout like '" + textBox9.Text + "%'and Duration <= " + textBox10.Text + " ;";
but if i insert data into it it will show like this command
It's mean that every function is subset of between right ?????
|
|
|
|
|
That's what it's supposed to do.
I suggest using DateTimePickers rather than TextBoxes, and parameterize the query.
|
|
|
|
|
Actully I've get the code but it 's too longgg
private void button4_Click(object sender, EventArgs e)
{
sql_con = new SQLiteConnection("Data Source= " + info + ".db;Version=3;New=False;Compress=True;");
sql_con.Open();
sql_cmd = sql_con.CreateCommand();
if ((radioButton1.Checked == true))
{
if (textBox10.Text != "")
{
if (textBox7.Text != "")
{
string CommandText = "select * from par where Time between '" + textBox7.Text + "%' and '" + textBox13.Text + "%' and Date like '" + textBox6.Text + "%' and Linein like'" + textBox8.Text + "%' and Lineout like '" + textBox9.Text + "%'and Duration >= " + textBox10.Text + " ;";
DB = new SQLiteDataAdapter(CommandText, sql_con);
DS.Reset();
DB.Fill(DS);
DT = DS.Tables[0];
dataGridView1.DataSource = DT;
int rowCount = ((DataTable)this.dataGridView1.DataSource).Rows.Count;
textBox12.Text = rowCount.ToString();
sql_con.Close();
MessageBox.Show("OK");
}
else
{
string CommandText = "select * from par where Date like '" + textBox6.Text + "%' and Linein like'" + textBox8.Text + "%' and Lineout like '" + textBox9.Text + "%'and Duration >= " + textBox10.Text + " ;";
DB = new SQLiteDataAdapter(CommandText, sql_con);
DS.Reset();
DB.Fill(DS);
DT = DS.Tables[0];
dataGridView1.DataSource = DT;
int rowCount = ((DataTable)this.dataGridView1.DataSource).Rows.Count;
textBox12.Text = rowCount.ToString();
sql_con.Close();
MessageBox.Show("OK");
}
}
else
{
if (textBox7.Text != "")
{
string CommandText = "select * from par where Time between '" + textBox7.Text + "%' and '" + textBox13.Text + "%' and Date like '" + textBox6.Text + "%' and Linein like'" + textBox8.Text + "%' and Lineout like '" + textBox9.Text + "%' ;";
DB = new SQLiteDataAdapter(CommandText, sql_con);
DS.Reset();
DB.Fill(DS);
DT = DS.Tables[0];
dataGridView1.DataSource = DT;
int rowCount = ((DataTable)this.dataGridView1.DataSource).Rows.Count;
textBox12.Text = rowCount.ToString();
sql_con.Close();
MessageBox.Show("OK");
}
else
{
string CommandText = "select * from par where Date like '" + textBox6.Text + "%' and Linein like'" + textBox8.Text + "%' and Lineout like '" + textBox9.Text + "%' ;";
DB = new SQLiteDataAdapter(CommandText, sql_con);
DS.Reset();
DB.Fill(DS);
DT = DS.Tables[0];
dataGridView1.DataSource = DT;
int rowCount = ((DataTable)this.dataGridView1.DataSource).Rows.Count;
textBox12.Text = rowCount.ToString();
sql_con.Close();
MessageBox.Show("OK");
}
}
}
else if ((radioButton2.Checked == true))
{
if (textBox10.Text != "")
{
if (textBox7.Text != "")
{
string CommandText = "select * from par where Time between '" + textBox7.Text + "%' and '" + textBox13.Text + "%' and Date like '" + textBox6.Text + "%' and Linein like'" + textBox8.Text + "%' and Lineout like '" + textBox9.Text + "%'and Duration <= " + textBox10.Text + " ;";
DB = new SQLiteDataAdapter(CommandText, sql_con);
DS.Reset();
DB.Fill(DS);
DT = DS.Tables[0];
dataGridView1.DataSource = DT;
int rowCount = ((DataTable)this.dataGridView1.DataSource).Rows.Count;
textBox12.Text = rowCount.ToString();
sql_con.Close();
MessageBox.Show("OK");
}
else
{
string CommandText = "select * from par where Date like '" + textBox6.Text + "%' and Linein like'" + textBox8.Text + "%' and Lineout like '" + textBox9.Text + "%'and Duration <= " + textBox10.Text + " ;";
DB = new SQLiteDataAdapter(CommandText, sql_con);
DS.Reset();
DB.Fill(DS);
DT = DS.Tables[0];
dataGridView1.DataSource = DT;
int rowCount = ((DataTable)this.dataGridView1.DataSource).Rows.Count;
textBox12.Text = rowCount.ToString();
sql_con.Close();
MessageBox.Show("OK");
}
}
else
{
if (textBox7.Text != "")
{
string CommandText = "select * from par where Time between '" + textBox7.Text + "%' and '" + textBox13.Text + "%' and Date like '" + textBox6.Text + "%' and Linein like'" + textBox8.Text + "%' and Lineout like '" + textBox9.Text + "%' ;";
DB = new SQLiteDataAdapter(CommandText, sql_con);
DS.Reset();
DB.Fill(DS);
DT = DS.Tables[0];
dataGridView1.DataSource = DT;
int rowCount = ((DataTable)this.dataGridView1.DataSource).Rows.Count;
textBox12.Text = rowCount.ToString();
sql_con.Close();
MessageBox.Show("OK");
}
else
{
string CommandText = "select * from par where Date like '" + textBox6.Text + "%' and Linein like'" + textBox8.Text + "%' and Lineout like '" + textBox9.Text + "%' ;";
DB = new SQLiteDataAdapter(CommandText, sql_con);
DS.Reset();
DB.Fill(DS);
DT = DS.Tables[0];
dataGridView1.DataSource = DT;
int rowCount = ((DataTable)this.dataGridView1.DataSource).Rows.Count;
textBox12.Text = rowCount.ToString();
sql_con.Close();
MessageBox.Show("OK");
}
}
}
else
{
if (textBox7.Text != "")
{
string CommandText = "select * from par where Date like '" + textBox6.Text + "%' and Linein like'" + textBox8.Text + "%' and Lineout like '" + textBox9.Text + "%' and Time between '" + textBox7.Text + "%' and '" + textBox13.Text + "%' ;";
DB = new SQLiteDataAdapter(CommandText, sql_con);
DS.Reset();
DB.Fill(DS);
DT = DS.Tables[0];
dataGridView1.DataSource = DT;
int rowCount = ((DataTable)this.dataGridView1.DataSource).Rows.Count;
textBox12.Text = rowCount.ToString();
sql_con.Close();
MessageBox.Show("OK");
}
else
{
string CommandText = "select * from par where Date like '" + textBox6.Text + "%' and Linein like'" + textBox8.Text + "%' and Lineout like '" + textBox9.Text + "%' ;";
DB = new SQLiteDataAdapter(CommandText, sql_con);
DS.Reset();
DB.Fill(DS);
DT = DS.Tables[0];
dataGridView1.DataSource = DT;
int rowCount = ((DataTable)this.dataGridView1.DataSource).Rows.Count;
textBox12.Text = rowCount.ToString();
sql_con.Close();
MessageBox.Show("OK");
}
}
}
|
|
|
|
|
I want to develop a pdf printer. I can pass any type of document to the pdfprinter so that it will generate the PDF file.
i have used the Ghostscript 8.56 and my Operating System is :XP.
1.I can get the Postscript file (.ps)
2. Unable to convert to .pdf
I don't know where i did mistake, my code is as follows :
string command = "gswin32c.exe -q -dNOPAUSE -dBATCH - sDEVICE=pdfwrite -sOutputFile=" + path + " -fd:\\GSOUTPUT.PS";
Process pdfprocess = new Process();
StreamWriter write;
StreamReader read;
ProcessStartInfo info = new ProcessStartInfo("command");
info.WorkingDirectory = System.AppDomain.CurrentDomain.BaseDirectory;
info.CreateNoWindow = false;
info.UseShellExecute = false;
info.RedirectStandardInput = true;
info.RedirectStandardOutput = true;
pdfprocess.StartInfo = info;
pdfprocess.Start();
write = pdfprocess.StandardInput;
read = pdfprocess.StandardOutput;
write.AutoFlush = true;
write.WriteLine(command);
write.Close();
ret = read.ReadToEnd();
Pls help me to create pdf....
Thanks in Advance.
Regards
Doni
|
|
|
|
|
Hello all
I am using WebMethod and File.Move
But my problem is the file is being locked by the WebMethod and it cannot be moved again (I want to rename it, not move it)
The exception thrown is "The process cannot access the file because it is being used by a another process"
How do I solve this?
I probably googled for half an hour
Here is my code:
[WebMethod]
public void EditFile(string FilePath, string NewName, string OldName)
{
File.Move(FilePath + OldName, FilePath + NewName);
}
|
|
|
|
|
You cannot move or rename a file that is in use. You need to make sure whatever has the file open closes it first.
What do you mean when you say "locked by the WebMethod". Is it your own code that has the file open? You just need to make sure you close the file before you try and rename it. (Post your code that opens/reads the file)
Simon
|
|
|
|
|
Im using jQuery ajax method to call the webservice
$.ajax({
type: "POST",
url: "fileManager/WebService.asmx/EditFile",
contentType: "application/json; charset=utf-8",
dataType: "json",
data: "{'FilePath':'" + filePath + "', 'NewName':'" + newName.val() + "', 'OldName':'" + oldName.text() + "'}",
});
The file is used in a tag
No where else, hope you understand.
It only works the first time I try it, the next it throws an error
|
|
|
|
|
Casper Hansen wrote: The file is used in a tag
Then you can't rename it. If a file is being used somewhere else, so you can't move or rename it until you stop using it.
What is it you are trying to do?
Simon
|
|
|
|
|
hi,
I have an application that contains several forms.
At a given time an user can be accessing any of the forms.In such a case whre exactly do i put my code to check for user idle time that is with which event do i associate this code to check for idle time?
Can i create a job for this purpose? if so how do i get the job to run at specific intervals in the background while the main application runs?
|
|
|
|
|
There is no event for this I discovered. System wide Idle can be easily checked but not application constrained.
I needed this in a previous application myself so ended up creating a component to do it. You could maybe use the component in my article[^] to acheive this.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
What exactly is idle time?
When a user is reading the form and figuring out what to do with it?
When the user has determined what to do and is moving the mouse to a button?
I'd also want to know why you want to measure it.
|
|
|
|
|
what is the size of reference variable
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
|
|
|
|
|
Size doesn't matter.....
forgot the joke icon
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
This was the question asked me in an interview.
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
|
|
|
|
|
OK - that has to be a contender for daftest technical question you're likely to receive in an interview. Unless you're going for a really senior post, I wouldn't expect that you'd carry this round in your head. I certainly wouldn't mark you down for not knowing it.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
That's actually a very good question and I think its 12 bytes (on a 32 bit system). 4 of those are the pointer or the reference, then there's some internal thing (garbage collection?) and I think there's a synchronisation part too.
Of course, that's not taking into account whatever you've got on the heap which actually represents your object.
I do know for sure that if you're storing vast collections of simple objects it's better to use struct s rather than class es. This saves that overhead.
Regards,
Rob Philpott.
|
|
|
|
|
Rob Philpott wrote: I think its 12 bytes
IMO at run-time a reference is just a pointer, no more no less, hence 4 or 8B.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Agreed, just 4/8 bytes on the stack. But on the heap you get the extra eight bytes on top of the object itself. I think - not certain.
Someone, somewhere did a wonderful job of explaining it all here on CP.
Regards,
Rob Philpott.
|
|
|
|
|
|
Thanks. Too long to read right now.
In the mean time I think we understood the question in different ways.
"What is the size of a reference variable?" to me means "What is the size of a reference?" (hence 4 or 8B) and not "What is the size of an object?". Which I guess gets dealt with in the article; I hope it also mentions objects get aligned in memory, I think to a 32B boundary. So, assuming that is correct, the smallest object costs 32B of heap space.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Luc Pattyn wrote: So, assuming that is correct, the smallest object costs 32B of heap space.
At the risk of really being quite boring, I was playing around with that the other day, trying to work out how much space a boolean takes as a class member variable.
Turns out the first one takes 32 bits, the second no bits, the third no bits, the fourth no bits, the fifth 32 again, etc. etc.
So, sort of one byte collectively rounded up to the nearest 32 bit word.
Regards,
Rob Philpott.
|
|
|
|
|
No surprise here. That is due to padding (inserting unused bytes, or rounding up the address), exactly like what happens when storing bytes in a C/C++/C# structure. By default elements of a struct (and the overall size of a struct) get word-aligned to prevent an access to the next 16-bit or larger quantity to cause a performance hit or an exception.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Cool.
Regards,
Rob Philpott.
|
|
|
|