I have well formatted .sql queries file, it contains insert/updates queries. I need to validate each query data in database before execution to database and this i need to do for every single query using C#.net collection.
if records are 1 million then is it feasible to read every DML statement and validate against database tables? what is the best possible approach using C#?? please advise.
Validate definition #1: Validate that the query will or will not return something. Not possible unless you duplicate the database and then run the query on the second data store.
Validate definition #1: Validate the syntax. Presumably you are using TSQL (MS SQL Server) I know for a fact that one could not fully 'validate' PSQL (Oracle) without running it against the database. The same, in some situations would exist with TSQL. There are code libraries that allow for SQL parsing which in turn leads to some form of validation. However, that is a limited form. For example it could validate that column names were of the correct form but not whether they exist or not. You could expand the parser to provide entity name checking however that requires that you have a confirmed up to date source of entity names (must match target database.)
I want to validate if the data which I am going to Update is already exist in DB or not and i can check it using ifexist().
But The issue with multiple DML statement may be upto 1 million records so do i need to keep checking in foreach loop for such big iterations in C#?
If you are just updating the data, why do you need to check if it exists or not? Using a WHERE clause in your SQL statement is the way to confine it to data that is already present. Alternatively, if you need to insert missing records and update others, check if your database uses something called an UPSERT query. As the name suggests, this query updates or inserts depending on whether or not the query condition can be satisfied. As you haven't said what database engine you are using, I'm going to link to an example in SQL Server to give you some ideas. SQL Server – How to write an Upsert using MERGE | My Adventures in Coding[^]
So a restatement of your original question to provide the actual problem.
You have a large number set of data that originates from outside of the database.
You need to process that data either by creating new records or updating existing ones.
So to start with, at least a few years ago (probably 10) universally it was always much more efficient to use database specific command line tools to batch process data. So you don't use C# at all. Although your C# might be used to initially produce the file which is then used for the batch processing.
As the other poster noted you database might support syntax that will do either an update or an insert. However if that is not the case then you can load the data into a different table and then, in the database itself (not C#) process the data to move it into the correct table(s).
You can also do further research by using "batch", "large" and "records" along with your actual database to seek other solutions.
Please suggest how can we print multiple files in one go. I am getting all files from a folder and the files are in different formats(pdf,jpg,bmp,msg,word,text).
Please suggest how can we do this in C#(web Forms).
It rather depends on whether the files are in a printable form already. If yes, then you can just send them direct to the printer. If no, then you will need to read the content and reformat it first. See Print spooler[^] for information which may be useful.
Web applications don't get much control of print queues. This means that web printing is in the control of the browser so if you want to print all these together, you are going to have to combine them all into one source that can then be printed out. I would suggest combining them into a PDF.
I have created groups example,supplierName and Date .I have store each supplier amount in one field .I want this each supplier amount sum in grand total...I have join Two table in databse.no of product are display...
I'm writing a C# WPF application that contains two stacked StackPanels. When the user clicks on Panel1 it's height value changes expanding the space between Panel1 and Panel2. When the user clicks on Panel2 it's height is expanded and Panel1's height is set back to it's original value. I am able to get this working in the xaml code:
However, I'm trying to do the same thing programmatically, so that I can determine at runtime what the new height should be when the user clicks on a panel. I implemented the following EventHandler, but it doesn't work (the Panel heights do not change).
privatevoid Panel1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
DoubleAnimation oMenuAnimation = new DoubleAnimation();
oMenuAnimation.From = 26;
oMenuAnimation.Duration = new Duration(new TimeSpan(0, 0, 0, 500));
oMenuAnimation.AccelerationRatio = .6;
oMenuAnimation.DecelerationRatio = .4;
Storyboard s = new Storyboard();
Storyboard.SetTargetProperty(oMenuAnimation, new PropertyPath("Height"));
DoubleAnimation oMenuAnimation2 = new DoubleAnimation();
oMenuAnimation2.To = 26;
oMenuAnimation2.Duration = new Duration(new TimeSpan(0, 0, 0, 500));
oMenuAnimation2.AccelerationRatio = .6;
oMenuAnimation2.DecelerationRatio = .4;
Storyboard.SetTargetProperty(oMenuAnimation2, new PropertyPath("Height"));
I`m trying to simulate clicks on toolbar entrys and checkboxes on a third party application.
"Pls don`t schold with me.. I`m at the beginning of my c# carrer "
Atm. I was trying it on notepad++. I was able to start the process, and send a message with SendMessage. I got the needed informations through Spy++/WindowDetective.
Process p = Process.Start(@"C:\Program Files (x86)\Notepad++\notepad++.exe");
IntPtr h = p.MainWindowHandle;
IntPtr child = FindWindowEx(h, newIntPtr(0), "Scintilla", null);
SendMessageW(child, 0x000C, 0, "Test \n test2");
I understood that with SendMessage I have to find first the needed class where i want to do something and use the right parameters to do the wanted imputs like mouseklick and keypresses. I was able to find them on mouse_event function (Windows)[^]. But about the WParam and LParam am I still confused cause it depends which imput i am using what I have to put on WParam and LParam. Maybe someone can explain it for a noob...
Now my problem is, i want to try some mouseklicks on the toolbar in the "Settings" ContextMenu. But I can not find it with Spy++ or other tools. It is not possible to do a click on it by the "Visual" Name like in AutoIT?
I have another tool where I have some checkboxes and I want to check it if its checked or not but there I can not get any class too. How could I solve it?
I found a nice Tool from Visual Studio (CUIT) but its only in the Enterprise-Version available.
The library that you are talking about is called, .NET Core, and it does not support a cross-platform GUI, it would support a UI for Windows only, and rest of the systems do not support that at the moment.
If you want to learn cross-platform development with C#, stick to .NET Core and only build native applications, that run on terminals. Since graphics are not supported, officially. There are several other frameworks that you can use for graphics, but remember, they would require other dependencies and would come with their own learning slopes.
If you still do want to learn GUI, then yes, you need something like that.
Read a few of the following threads and discussions going on under this .NET Core thing,
I'm trying to add a context menu to Watch (and Local) window to Visual Studio (2017). I was able to add the context menu, however I don't know how to obtain the selected item (expression) from the context menu command code.
Last Visit: 31-Dec-99 18:00 Last Update: 22-Jul-17 0:56