|
I have tried this but i didn't get the error you mentioned.
private void button1_Paint(object sender, PaintEventArgs e)
{
string printstr = "the string length is more it is not getting printed properly so i have tried to split";
string actualstring = "i am printing a string through printer as the string length is more it is not getting printed properly so i have tried to split the string and the printing but it is showing error at run time ";
int printstrlength = printstr.Length;
int limit = 10;
int startindex = 0;
int x = 2;
int y = 5;
for (int i = 0; printstr != null; i++)
{
if (limit > printstrlength)
{
printstr = actualstring.Substring(startindex, printstrlength);
e.Graphics.DrawString(printstr, button1.Font, Brushes.Black, new Point(x, y));
break;
}
else
{
printstr = actualstring.Substring(startindex, limit);
e.Graphics.DrawString(printstr, button1.Font, Brushes.Black, new Point(x, y));
}
y += 20;
startindex = limit + 1;
limit += 40;
}
}
|
|
|
|
|
That is because your code is incorrect. Start with the actualstring length and see what happens.
|
|
|
|
|
i my generating the qrcode using ONBarcode.dll but in this sometimes some default text are getting printed on qr code as it is not free. Can anyone suggest any dll file for generating qr code and there should not be any licence for that.
|
|
|
|
|
Did you know that one of the best tools a developer can have is the ability to work out how to search information sources for themselves and apply critical thinking to solve problems? By doing this, I worked out that you should run a query that looks a bit like this[^]. This gives you many, many potential sources for your answer.
This space for rent
|
|
|
|
|
how we can adjust the size of qr code while printing through printer
|
|
|
|
|
We can't answer that question as it stands - we have no idea how you are printing the QR code: what package(s) you are using, where you generate the QR code from, how you send it to the printer - anything at all really, except that QR codes, printing, and (probably) C# code are involved.
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work from.
So show us the relevant code fragments, explain what happens when you use them, tell us exactly what you want to happen. We can't help you without that!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
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?
|
|
|
|