|
goal:
Display all records from a specified table in a Visual Foxpro database in a DGV.
This would not be a problem, except, i only want those rows which have a record id contained by a BindingList<string> TableId
I've tried this:
OledbConnection = new OleDbConnection(connectionString);<br />
OledbCommand = new OleDbCommand(query,connection);<br />
OleDbDataAdapter dataAdapter = new OleDbDataAdapter(query, connection);<br />
<br />
<br />
foreach(string id in TableId)<br />
{<br />
query = "SELECT * FROM " + tableName + " WHERE (" + tableRecordIDColumn + " = '" + id + "') ORDER BY " + tableRecordIDColumn;<br />
command.CommandText = query;<br />
dataAdapter.SelectCommand = command;<br />
dataAdapter.Fill(dataTableFromDb);<br />
}<br />
bindingSource1.DataSource = dataTableFromDb;<br />
dataGridView1.AutoGenerateColumns = true;<br />
dataGridView1.DataSource = bindingSource1;
Allthough this works, it's extremely slow. Especially since my BindingList<string> TableId could contain 20 000 record id's.
Would there be any way to create a dataset with two tables on wich i could excecute a select query wich an inner join on the record id's??
And then use the results as the DataGridView.DataSource?
grts, thx
|
|
|
|
|
sharp source, the problem is: you do to many connections to DB.
I can propose two different solutions:
1) We can include all of this in one SQL:
'OR' version:
<br />
string queryCondition = "";<br />
foreach (string id in TableId)<br />
{<br />
queryCondition += tableRecordIDColumn + " = '" + id + "' OR ";<br />
}<br />
if (queryCondition != "") queryCondition = queryCondition.Remove(queryCondition.Length - 4);<br />
<br />
string query = "SELECT * FROM " + tableName + " WHERE (" + queryCondition + "') ORDER BY " + tableRecordIDColumn;<br />
'In' version:
<br />
string queryCondition = "";<br />
foreach (string id in TableId)<br />
{<br />
queryCondition += "'" + id + "', ";<br />
}<br />
if (queryCondition != "") queryCondition = queryCondition.Remove(queryCondition.Length - 2);<br />
<br />
queryCondition = tableRecordIDColumn + " in (" + queryCondition + ")";<br />
<br />
string query = "SELECT * FROM " + tableName + " WHERE (" + queryCondition + "') ORDER BY " + tableRecordIDColumn;<br />
Remark: You can get an exception like "the query is too long" (because of 2000 entries). You can split them to 100th packs, for example
2) Restricting the logic of data getting (I think it is better)
I think you can find an way to get more simple selecting condition
>>Would there be any way to create a dataset with two tables on wich i could excecute a select query wich an inner join on the record id's??
You can. You can load all data to data. Then you just need to filter the data by using BindingSource class. But this solution is valid when you have to filter data many times per minute.
-- modified at 9:13 Thursday 7th June, 2007
|
|
|
|
|
Your 2 first suggestions i allready tried. And as you say, i need to limit the data getting.
Btw, it's not 2000 but 20 000 rows....
So restricting the logic of data getting.
How would i do that?
So i create a dataset
Add two DataTables
OledbDataAdapter.Fill(DataTable1);
How do i get the BindingList<string> TableId into a table?
And after I have a dataset with the two tables... I gues i can figure that out.
Thx
|
|
|
|
|
>> And as you say, i need to limit the data getting.
Do you want to get a code with splitting by 1000 (for example) Ids?
>> So restricting the logic of data getting.
I meant "restructuring", sorry. So change the logic of the app. To group some ID into groups...
I need to see you task to give you more ideas.
>> How do i get the BindingList TableId into a table?
>>And after I have a dataset with the two tables... I gues i can figure that out.
No, you will have one table with full data in it.
But you will display only necessary information.
To do that you have to bind you table to DataGridView (for example) through BindingSource:
<br />
BindingSource bs = new BindingSource(someDataSet, "SomeMember");<br />
someDataGridView.DataSource = bs;<br />
<br />
<br />
<br />
bs.Filter = "SomeColumn = 'id1' OR SomeColumn = 'id2' OR ..... ";<br />
|
|
|
|
|
how to create dynamic text boxes in c#.net
|
|
|
|
|
|
Textbox txt=new Textbox();
Controls.Add(txt);
txt.show();//it wud display txt at top-left corner of the form
-- modified at 8:11 Thursday 7th June, 2007
Regards
Chintan
www.visharadsoft.com
(Nothing is so purify as KNOWLEDGE)
|
|
|
|
|
There is no reason to call method show.
Any control is shown up on the form at time it has been added to form's component container
P.S. Chintan.Desai, there were many syntax mistakes in you post
|
|
|
|
|
What did you mean: "dynamic text boxes"?
May be you wanted to say how to create text boxes dynamically?
There is the solution:
<br />
private void Form1_Load(object sender, EventArgs e)<br />
{<br />
TextBox myDynamicTextbox = new TextBox();<br />
myDynamicTextbox.Size = new Size(100, 20);<br />
myDynamicTextbox.Location = new System.Drawing.Point(10, 10);<br />
<br />
this.Controls.Add(myDynamicTextbox);<br />
}<br />
|
|
|
|
|
|
The trick is to use a Graphics object obtained from the Image and use that for drawing.
GraphicsPath gp = new GraphicsPath();
Bitmap bmp = new Bitmap(200, 200);
using (Graphics g = Graphics.FromImage(bmp))
{
System.Drawing.Pen pen = System.Drawing.SystemPens.InfoText;
g.DrawPath(pen, gp);
}
|
|
|
|
|
I'm attempting to set up a text input field so that keyboard entry is rejected, but barcode scanner via usb is accepted. How can I programmatically distinguish between the keyboard and a USB based bar code scanner?
|
|
|
|
|
Most of the time, a barcode scanner will supply the data it scans as keystrokes. There's no way to tell the difference between the two.
If the barcode scanner exposes an API, you'd have a much easier time with this since you get the data from the API.
But, disabling keyboard input on this field is a bad idea. What does the user do if the barcode scanner fails??
|
|
|
|
|
private void nPic_MouseDown(object sender, MouseEventArgs e)
{
MessageBox.Show("ok");
}
private void pnlMap_MouseClick(object sender, MouseEventArgs e)
{
nPic = new PictureBox();
nPic.Name = "test"
this.nPic.MouseDown += new System.EventHandler(this.nPic_MouseDown);
}
Error 9 No overload for 'nPic_MouseDown' matches delegate 'System.EventHandler'
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Instead of System.EventHandler write System.Windows.Forms.MouseEventHandler (or probably just MouseEventHandler).
|
|
|
|
|
Good, thanks!
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Hai Everybody,
I want to connect and work with the FileMaker applicaiton through ASP.net.
Can anyone give me a reference.
Best Regards,
M. J. Jaya Chitra
|
|
|
|
|
M. J. Jaya Chitra wrote: ...through ASP.net.
Can anyone give me a reference.
ASP.Net forum
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Thank you for your valuable suggestions
Best Regards,
M. J. Jaya Chitra
|
|
|
|
|
Can you please tell me how to connect it with a .net application and also a reference site for the commands that can be user in filemaker
Best Regards,
M. J. Jaya Chitra
|
|
|
|
|
Sorry, I'm not into Asp and this's why I tried to suggest you the Asp.Net forum.. did you look through the software documentation??
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Ok
Best Regards,
M. J. Jaya Chitra
|
|
|
|
|
Hi All,
I am been stuck with Drag-Drop operation in C#.I wanna to click on picture1,move it and dropped on picture2.but Drag_Enter event for picture2 does not fired at all. I have seek many topics but not got any any idea!!. I m bit confus with DoDragDrop().Pls tell something about e.Effect and e.Data.GetDataPresent(). I am been stuck with my project. from last 3 days. pls pls help me!!!
Regards
Chintan
www.visharadsoft.com
(Nothing is so purify as KNOWLEDGE)
|
|
|
|
|
1. Replace your PictureBox with a panel control and set it's background image to the picture you want.. "that should do the trick nicely!"
2. Enable the panel "Allow Drop" property by setting it to true ie. Panel1.AllowDrop = true;
3. Enable the destination's AllowDrop property as well.
4. In the destination's drag over, set the effect e.Effect = DragDropEffects.Move; Move/Copy/All/None.. etc.
5. If you want to say drag a file(s) use this:
private void listBox1_DragDrop(object sender, DragEventArgs e)
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
foreach (string file in files)
{
try
{
if (!listBox1.Items.Contains(file))
listBox1.Items.Add(file);
listBox1.SelectedIndex = listBox1.Items.Count - 1;
}
catch (Exception ex)
{
MessageBox.Show("Cannot find "+file, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Thanks for ur reply,
i hav done the same thing as wht u tol,but friend when i click on dragged picture box (picturebox1)which i need to move,its not moving on MouseMove event(if i dont write DoDragDrop() in mouseMove it will work fine.I have written code to move picturebox1 according to mouse position).Only mouse get moved and then after taking mouse over panel1,Panel1_DragEnter is fired.But i want panel to know that it is picturebox1
my code snippet.it will give u some info.
private void picturebox1_MouseMove(object sender, MouseEventArgs e)
{
DagDropEffects ddEffect = picturebox1.DoDragDrop(picturebox1, DragDropEffects.Move);
if (ddEffect == DragDropEffects.Move)
{
//then move the mouse else dont move it
}
}
//Code in target picture box Drag_Enter event
private void picturebox2_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.Bitmap))
//then it is valid control
else
//not valid so dont allow to drop on target picture box
}
pls reply
-- modified at 6:54 Thursday 7th June, 2007
Regards
Chintan
www.visharadsoft.com
(Nothing is so purify as KNOWLEDGE)
|
|
|
|