|
Hi ,
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.
modified 27-Jun-17 14:31pm.
|
|
|
|
|
What do you mean by "validate".
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
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[^]
This space for rent
|
|
|
|
|
Sure thanks for direction Pete.
|
|
|
|
|
You're most welcome.
This space for rent
|
|
|
|
|
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.
|
|
|
|
|
Hi,
I created my regex like the following:
Regex regexEET = new Regex(".*?EET.*?");
But this one also detects "eet".
I was wondering how can I modify it to only search for uppercase "EET".
Thank you.
|
|
|
|
|
That should only match strings containing EET in upper case. Please show the actual content that you are matching against?
|
|
|
|
|
When I run your regular expression, I only get matches for EET. You haven't specified any regex options have you?
This space for rent
|
|
|
|
|
Oh my! You guys are right!
Regex regexEEST = new Regex(".*?EEST.*?",
RegexOptions.IgnoreCase |
RegexOptions.CultureInvariant |
RegexOptions.IgnorePatternWhitespace |
RegexOptions.Compiled);
I didn't notice
RegexOptions.IgnoreCase
Thank you, your comments were very helpful.
|
|
|
|
|
It's an easy mistake to make. Glad you got it sorted.
This space for rent
|
|
|
|
|
Hi All,
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).
Thanks in Advance
Regards
Binod
|
|
|
|
|
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.
This space for rent
|
|
|
|
|
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...
|
|
|
|
|
Can we reuse the Visual Studio Unit Test in other unit test ?
|
|
|
|
|
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:
<pre> <StackPanel Margin="1,1,1,1" Grid.ColumnSpan="3">
<StackPanel Name="Panel1" Height="26">
<Label HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Content="Menu_1" Foreground="White" FontWeight="Bold" MouseLeftButtonUp="Panel1_MouseLeftButtonUp">
<Label.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF80CEF3" Offset="0.01"/>
<GradientStop Color="#FF5588A0" Offset="1"/>
</LinearGradientBrush>
</Label.Background>
</Label>
<StackPanel.Triggers>
<EventTrigger RoutedEvent="UIElement.MouseLeftButtonUp">
<BeginStoryboard >
<Storyboard x:Name="Animation1">
<DoubleAnimation Storyboard.TargetName="Panel1" Storyboard.TargetProperty="Height" To="646" Duration="0:0:0.50" AccelerationRatio="0.6" DecelerationRatio="0.4" />
<DoubleAnimation Storyboard.TargetName="Panel2" Storyboard.TargetProperty="Height" To="26" Duration="0:0:0.50" AccelerationRatio="0.6" DecelerationRatio="0.4" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</StackPanel.Triggers>
</StackPanel>
<StackPanel Name="Panel2" Height="26">
<Label HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Content="Menu_2" Foreground="White" FontWeight="Bold">
<Label.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF80CEF3" Offset="0.01"/>
<GradientStop Color="#FF5588A0" Offset="1"/>
</LinearGradientBrush>
</Label.Background>
</Label>
<StackPanel.Triggers>
<EventTrigger RoutedEvent="UIElement.MouseLeftButtonUp">
<BeginStoryboard>
<Storyboard x:Name="menu">
<DoubleAnimation x:Name="Menu_1" Storyboard.TargetName="Panel1" Storyboard.TargetProperty="Height" To="26" Duration="0:0:0.50" AccelerationRatio="0.6" DecelerationRatio="0.4" />
<DoubleAnimation x:Name="Menu_2" Storyboard.TargetName="Panel2" Storyboard.TargetProperty="Height" To="646" Duration="0:0:0.50" AccelerationRatio="0.6" DecelerationRatio="0.4" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</StackPanel.Triggers>
</StackPanel>
</StackPanel>
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).
private void Panel1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
DoubleAnimation oMenuAnimation = new DoubleAnimation();
oMenuAnimation.From = 26;
oMenuAnimation.To =646;
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"));
Storyboard.SetTarget(oMenuAnimation,Panel1);
Storyboard.SetTargetName(oMenuAnimation, "Panel1");
s.Children.Add(oMenuAnimation);
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"));
Storyboard.SetTarget(oMenuAnimation2, Panel2);
s.Children.Add(oMenuAnimation2);
s.Begin();
}
Does anyone know what I may be doing wrong?
|
|
|
|
|
Hi girls and guys.
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");
p.WaitForInputIdle();
IntPtr h = p.MainWindowHandle;
SetForegroundWindow(h);
IntPtr child = FindWindowEx(h, new IntPtr(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.
Ty for your time.
Edit: Does no one have a clue?
modified 27-Jun-17 10:32am.
|
|
|
|
|
Greetings all!
I'm interested in learning C# now, and excited to hear that Microsoft has released a library that makes Mono no longer a requirement, for it to run under Linux and MacOS X.
This being said, would I need to use a tool native to each OS to design the GUI?
thanks for the feedback in advance!
Chris
|
|
|
|
|
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,
Cross Platform GUI - .NET Foundation Forums
c# - How can I develop cross-platform gui application using .Net Core - Stack Overflow
coreclr - Is it possible to make desktop GUI application in .NET core? - Stack Overflow
Cross-Platform Graphics in .NET Core – Cameron Aavik – Medium
But who knows, maybe in the next versions we might get some GUI cross-platform, or one of the best tools (WPF, for instance), gets open sourced. At the moment, .NET Core 2 is the latest. core/2.0.0-preview1.md at master · dotnet/core · GitHub
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Member 13275688 wrote: This being said, would I need to use a tool native to each OS to design the GUI? First you'd need to decide which UI; you could use WinForms on both platforms, GTK or support both.
I've used Visual Studio to create WinForms to be used with Mono. The WinForm implementation differs a tiny bit from the MS implementation, so you will have to test the results.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
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.
Thanks Abyss
|
|
|
|
|
Hi,
I have a Console Application which is Scheduled as Scheduled Task, for some reason maybe because of the NetWork issues the Scheduled task is showing running unlimited time and not processing any files or records which are over the network.
Now I want find out in my Console Application if the Task is running and waiting for more than 1 hr send us an Email, can anybody please let me know which approach is better for this, like do we have something in the Windows Scheduler Task to set this setting? Or can I write some code in my Console App to check how long the Task is working for and send an Email or stop it if its too late.
Thanks in advance, any help can be greatly appreciated.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|