|
Thanks, My application is single-user.
|
|
|
|
|
CE doesn't support SP's, nor is it multi-user.
So, you can query the database from your app for the record you're trying to add.
|
|
|
|
|
He's anti-SQL. Doesn't know it; doesn't want to learn it. Every solution is C# only; even if it's a database app.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
Well then, he's really screwing himself, isn't he?
EDIT:
Why did I just get the feeling he's going to be coming back bitching about more performance problems because he doesn't have any indexing setup?
|
|
|
|
|
He won't accept that without "SQL" everything has to be downloaded to the client; that's why he'll always have performance issues.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
No, I'm serious about my work. I just want to learn.
|
|
|
|
|
yes, I don't have enough knowledge about SQL query but this does not mean I hate it or I don't want to learn it. I'm trying to learn it now. Please don't leap to the conclusion like this.
|
|
|
|
|
Alex Dunlop wrote: I'm trying to learn it now. Then stop wasting time with questions here, and make use of one of the myriad tutorials on the subject: SQL Tutorial[^].
|
|
|
|
|
Create a unique index on the table:
CREATE INDEX (SQL Server Compact) | Microsoft Docs[^]
If the majority of values will be new, then just insert them and handle the constraint violation error which will be thrown when a duplicate value is inserted.
Otherwise, issue an UPDATE for the row and check the number of rows affected. If no rows were affected, issue an INSERT for the row.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I'm using advanced DataGridView (advDataGridView) in my project. it has Filter and Sorting capability. When my data rows is high enough, for example, more than 10000 rows, It takes some seconds to filter the string I'm searching. It's too laggy for dense DGV data. Is there any way to increase the string search speed? (Search as the speed of Excel filter)?
modified 30-May-21 5:07am.
|
|
|
|
|
A DataGridView is a visual control so every time you change something it needs to reorganise its content before refreshing the display, and that takes time. And the more rows you have the longer it takes. Putting more than around 100 rows on such a control at any one time is not a good idea. Use some backing control to do the filtering and sorting, and page the display. Do you really think your users want to try scrolling through thousands of rows?
|
|
|
|
|
As Richard has said, it's a bad idea to even try and throw that much data at users - all that will happen is they will stop using your app, and / or demand their money back. I would!
Filtering can be speeded up on a standard DataGridView by using a filter in a BindingSource instead of sourcing the data directly from a DataTable or similar - but you'd have to see if your control supports that.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
In my application, the user loads their data from Excel files. Those data are stored in a DataTable and then saved into a SQL CE file. Each time They load the application, these data are loaded from SQL into DataTable and then to DGV. This process is done very quickly and smoothly. The problem is that when I use filter icon above each column, because of the huge amount of rows DGV has, it gets my strings with time delay (laggy). For example I write AB332, but the input string area is filled slowly and with time delay. When I hit Filter button, Those data are filtered very quickly.
I need a way to solve this time delay when writing filter string.
NuGet Gallery | ADGV 0.1.0.10[^]
|
|
|
|
|
Basically, don't do it. As a "user experience", it's horrible - and probably useless because nobody is going to scroll through that many rows to find the information they are interested in.
But if you hate your users - and trust me, they will hate you - look at a binding source as I said.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Yeah, You're right. Is there any tutorial in YouTube or anywhere else which explains your way of filtering by an example? Can you give me a link?
|
|
|
|
|
Sorry, no = I avoid YouTube tutorials as they are mostly garbage made by people have no idea how to make a video, no idea how to teach, and more often than not not idea how to code either ...
Youy could start with Microsoft: BindingSource.Filter Property (System.Windows.Forms) | Microsoft Docs[^]
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Quote: They load the application, these data are loaded from SQL into DataTable and then to DGV. This process is done very quickly and smoothly.
You filter your "DataTable" (#1) into a new DataTable (#2); or filter in the SQL query; you "reload" the whole grid when filtering.
It would be impossible for this to run slower than your current "quick and smooth" part.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
Hello everyone,
I have made nice Interface for example with NotebookPlugin like that:
namespace ExampleApp.Interfaces
{
public interface INotebookPlugin
{
string LabelName { get; set; }
Gtk.Widget GetNotebook();
Gtk.Window CurrentWindow { get; set; }
}
}
I create pluginpaths with Array of string as string[] and I add PluginUtilities for different interfaces like I(name of plugin types)Plugin
public static IEnumerable<INotebookPlugin> LoadNotebookPlugin(string plugin_path)
{
string root = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Plugins"));
string pluginLocation = Path.GetFullPath(Path.Combine(root, plugin_path.Replace('/', Path.DirectorySeparatorChar)));
Assembly asm = Assembly.LoadFile(pluginLocation);
int count = 0;
foreach (Type type in asm.GetTypes())
{
if (typeof(INotebookPlugin).IsAssignableFrom(type))
{
if (Activator.CreateInstance(type) is INotebookPlugin result)
{
count++;
yield return result;
}
}
}
if (count == 0)
{
string availableTypes = string.Join(",", asm.GetTypes().Select(t => t.FullName));
throw new ApplicationException(
$"Can't find any type which implements INotebookPlugin in {asm} from {asm.Location}.\n" +
$"Available types: {availableTypes}");
}
}
You know it is same to AppWithPlugin.
And you know to create Window with GtkSharp 3.x
I made example with Gtk.Notebook
foreach (INotebookPlugin notebookPlugin in notebookPlugins)
{
notebookPlugin.CurrentWindow = this;
if (notebookPlugin.GetNotebook() != null)
notebook.AppendPage(notebookPlugin.GetNotebook(),
new Gtk.Label(notebookPlugin.LabelName));
}
Then you will create library for Plugin
public class SimpleTab : Gtk.VBox, INotebookPlugin
{
public SimpleTab() : base(false, 0)
{
Gtk.Button btn = new Gtk.Button("Open Dialog!");
PackStart(btn, false, false, 0);
btn.Clicked += delegate {
Gtk.MessageDialog md = new Gtk.MessageDialog(CurrentWindow, Gtk.DialogFlags.Modal, Gtk.MessageType.Question, Gtk.ButtonsType.Ok, "Hello I am loading from plugin.");
md.Run();
md.Destroy();
};
ShowAll();
}
public string LabelName { get; set; } = "SimpleTab";
public Gtk.Window CurrentWindow { get; set; }
public Gtk.Widget GetNotebook() => this;
}
Compile all then you create directory "Plugins" in Release or Debug and copy from Plugin's output dll file to Plugin directory of Application's output directory and prompt it:
dotnet run or mono Example.App.exe
Look my example application - I made with PowerHammer for Goldsrc Mapping... But It works in process. Because I have not idea before that is why I am too late to find and to resolve Plugin System like MEF, DotNetWithPlugins or other are not good because they assign to instances - But I love AppWithPlugin from Microsoft because It looks very promising for loading plugins - but I don't know before how do I load plugin with GtkSharp or WinForms ( I found here CodeProject ) But it is really catastrophically with MEF like it need instance of plugin assemblies.
That is why AppWithPlugin looks like it works close to old version of Mono / Net Frameworks 7.x
And I have success with GtkSharp 3 and Plugin System ( Loader )
If you bundle with mkbundle then It doesn't happen with Plugin assemblies if they can't load required references - It just works from bundled application with required assemblies and Plugins directory with single plugin assembly like SimpleTabNotebook.dll.
Note for Dotnet / Net Core - You shouldn't forget to package like this:
/.
./BundleExecutableOfNetCore ( Bundled by Dotnet )
./Plugins
/SimpleTabNotebook.dll
I hope you enjoy your happy coding with C# AppWithPlugin like function or my old assembly .
Sorry for my bad English!
|
|
|
|
|
This is probably the wrong place to post this - forums can move quite quickly, and unless this is on teh first page, it probably won't get seen.
Instead, post it as a Tip using this link: Submit a new Article[^] and it goes into more "permanent" and "searchable" storage where people might expect to find it.
You can also upload the source as a "ready to go" example, and add pictures of what your interface looks like.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Hello everyone,
my project get data from dataGridView after that convert rows to Multidimensional Arrays
and i want to assign Multidimensional Arrays to IList Interface but the IList Interface fill last row in gridview every time
my code
public IList<InvoiceLine> invoiceLines { get; set; }
InvoiceLine invoiceline = new InvoiceLine();
string[,] datavalu = new string[dataGridView1.Rows.Count, dataGridView1.Columns.Count];
foreach (DataGridViewRow row in dataGridView1.Rows)
{
foreach (DataGridViewColumn col in dataGridView1.Columns)
{
datavalu[row.Index, col.Index] = dataGridView1.Rows[row.Index].Cells[col.Index].Value.ToString();
}
}
int i ;
for ( i = 0; i < datavalu.GetLength(0); i++)
{
invoiceline.description = datavalu[i, 0].ToString();
invoiceline.itemType = datavalu[i, 1].ToString();
invoiceline.itemCode = datavalu[i, 2].ToString();
invoiceline.internalCode = datavalu[i, 3].ToString();
invoiceline.unitType = datavalu[i, 4].ToString();
invoiceline.quantity = int.Parse(datavalu[i, 5].ToString());
invoicelines.Add(invoiceline);
}
my data
description itemType itemCode internalCode unitType quantity
Food EGS EG-538486562-1314 1314 EA 1
Food2 EGS EG-538486562-1315 1500 EA 5
my problem is that invoicelines return 2 rows same data in last row in the grid
Food2 EGS EG-538486562-1315 1500 EA 5
Can anyone tell me why please
Thanks in advance
|
|
|
|
|
My first question is why are you using a DGV to store data or transfer data between models? That's not what it's for and results in slow, buggy code that can distort your data.
The DGV should be used for the display of data in some data model. That avoids the entire block of code you're messing with now.
|
|
|
|
|
Thank you for your response. buz i load csv file in grid view after that i want to convert this data to multidimensional arrays
|
|
|
|
|
That's a bad way to go. Controls should NEVER be used as your storage for data.
Your CSV should be parsed to a data structure designed to hold that data. Fields can be setup to hold strings, integers, doubles, or whatever you need, and the CSV parser just places the values in the appropriate fields with no conversion. The DGV can then be used to display it if needed.
Using the DGV as your storage makes accessing that data slow because you're now doing a bunch of converting to sting or other types that you wouldn't need to do otherwise.
For example, this is garbage. You're converting a value in the DGV to a string and then parsing that string as an integer. This code will also fail if you've got no value in that cell.
invoiceline.quantity = int.Parse(datavalu[i, 5].ToString()); Putting the data directly into a datastructure designed to hold it from the CSV parser is a much better way to go as you get to validate the data before you use or even display it and handle that occurrence at a more appropriate time, when it's being loaded.
|
|
|
|
|
You're absolutely right but I'm trying code and my problem isn't with grid view but my problem is with
how to fill invoicelines right
i try another way to show invoicelines in listBox1 and run good
string[,] datavalu = new string[dataGridView1.Rows.Count, dataGridView1.Columns.Count];
foreach(DataGridViewRow row in dataGridView1.Rows)
{
foreach (DataGridViewColumn col in dataGridView1.Columns)
{
datavalu[row.Index, col.Index] = dataGridView1.Rows[row.Index].Cells[col.Index].Value.ToString();
}
}
int i = 0;
foreach(string ss in datavalu)
{
listBox1.Items.Add(ss);
i++;
}
rustle
after that i change code to this but run wrong
for ( i = 0; i < datavalu.GetLength(0); i++)
{
invoiceline2.description = datavalu[i, 0].ToString();
invoiceline2.itemType = datavalu[i, 1].ToString();
invoiceline2.itemCode = datavalu[i, 2].ToString();
invoiceline2.internalCode = datavalu[i, 3].ToString();
invoiceline2.unitType = datavalu[i, 4].ToString();
invoiceline2.quantity = int.Parse(datavalu[i, 5].ToString());
invoicelines.Add(invoiceline);
}
some thing i miss can you help me
|
|
|
|
|
Because you only have one instance of the c lass and you insert it multiple times into the list. And each time round the loop you overwrite the values you set in the previous instance.
Think of it like cars: You put your mobile phone in the glove box of my car. Then you open the glove box of your car - is your mobile in there? Of course not - they are different cars.
What your loop is doing is parking my car in different spaces in the car park: and expecting each spot to be filled with a car at the end!
Create a new instance each time round the loop.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|