|
BillWoodruff wrote: We can't read your mind.
Wha??
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Hello I want to print 2 copy of Invoice
1. Original Copy
2. Duplicate copy
i want above text is written on bill on right upper side!
and this event is occurs on one button click
|
|
|
|
|
"I want" is not a question.
Show us what you have tried, tell us where you are stuck, and maybe somebody will be able to help you.
If you were expecting somebody to write the code for you, you've come to the wrong site.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
And?
What have you tried?
Where are you stuck?
What help do you need?
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Unless you're using "2 part paper", you can't claim an "original" and a "duplicate".
Maybe a "customer copy" ...
The Master said, 'Am I indeed possessed of knowledge? I am not knowing. But if a mean person, who appears quite empty-like, ask anything of me, I set it forth from one end to the other, and exhaust it.'
― Confucian Analects
|
|
|
|
|
Hi
I have two queries on a button click. One query inserts a new record in a access database table called Engineering, the other updates an already existing record. They both use the same set of variables which in turn get their values from textboxes on the form. The insert query runs fine. However when I run the update query I get a data type mismatch error. I have checked and rechecked the values to be placed in the database are correct. So I believe that the error is in the syntax of the where clause.
This is the Update query
The where clause gets it's string value 'n' from a textbox on the form called Name_textBox, Which in turn gets it's value from the Name field in the table.
string my_querry = "UPDATE Engineering SET Address = a, Phone = p, Email = em, DateBroughtIn = d, Donation = don, Repair = r, Warranty = war, Type = IT, Make = m, Model = MO, Serial = s, ReportedFault = RF, RepairedBy = i, FaultType = FT, Repaired = Rep, BER = BER, FaultFound = FF, DateTested = DT, DueDate = DueD, TestedBy = TestedBy, ConductorResistance = CPass, CReading = CR, InsulatorResistance = InRes, IReading = IR, EarthLeakage = EarthL, EReading = ER WHERE [Name] ='" + n + "'";
|
|
|
|
|
Since we're in the C# forum, care to show us how you assign the values to the parameters, and explain why you're not using a normal parameterized query?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Hi
I use this code to add the values to the parameters.
cmd.Parameters.AddWithValue("@n", this.Name_textBox.Text);
cmd.Parameters.AddWithValue("@a", this.Address_textBox.Text);
cmd.Parameters.AddWithValue("@p", this.Phone_textBox.Text);
cmd.Parameters.AddWithValue("@em", this.Email_textBox.Text);
cmd.Parameters.AddWithValue("@d", this.Date_textBox.Text);
cmd.Parameters.Add(new OleDbParameter("@don", OleDbType.Boolean));
cmd.Parameters.Add(new OleDbParameter("@r", OleDbType.Boolean));
cmd.Parameters.Add(new OleDbParameter("@war", OleDbType.Boolean));
cmd.Parameters.AddWithValue("@IT", this.Type_comboBox.Text);
cmd.Parameters.AddWithValue("@m", this.Make_textBox.Text);
cmd.Parameters.AddWithValue("@MO", this.Model_textBox.Text);
cmd.Parameters.AddWithValue("@s", this.Serial_textBox.Text);
cmd.Parameters.AddWithValue("@RF", this.ReportedFault_textBox.Text);
cmd.Parameters.AddWithValue("@i", this.RepairedBy_textBox.Text);
cmd.Parameters.AddWithValue("@FT", this.FaultType_comboBox.Text);
cmd.Parameters.Add(new OleDbParameter("@Rep", OleDbType.Boolean));
cmd.Parameters.Add(new OleDbParameter("@BER", OleDbType.Boolean));
cmd.Parameters.AddWithValue("@FF", this.FaultFound_textBox.Text);
if (DateTested_textBox.Text != "")
{
cmd.Parameters.AddWithValue("@DT", this.DateTested_textBox.Text);
cmd.Parameters.AddWithValue("@DueD", this.DueDate_textBox.Text);
cmd.Parameters.AddWithValue("@TestedBy", this.TestedBy_textBox.Text);
cmd.Parameters.Add(new OleDbParameter("@CPass", OleDbType.Boolean));
cmd.Parameters.AddWithValue("@CR", this.Conductor_textBox.Text);
cmd.Parameters.Add(new OleDbParameter("@InRes", OleDbType.Boolean));
cmd.Parameters.AddWithValue("@IR", this.Insulator_textBox.Text);
cmd.Parameters.Add(new OleDbParameter("@EarthL", OleDbType.Boolean));
cmd.Parameters.AddWithValue("@ER", this.Earth_textBox.Text);
}
else
{
cmd.Parameters.AddWithValue("@DT", "");
cmd.Parameters.AddWithValue("@DueD", "");
cmd.Parameters.AddWithValue("@TestedBy", "");
cmd.Parameters.AddWithValue("@CPass", false);
cmd.Parameters.AddWithValue("@CR", "");
cmd.Parameters.AddWithValue("@InRes", false);
cmd.Parameters.AddWithValue("@IR", "");
cmd.Parameters.AddWithValue("@EarthL", false);
cmd.Parameters.AddWithValue("@ER", "");
}
I have changed the checkbox lines from
cmd.Parameter.AddWithValue("@r, this.Repair_checkbox.checked); to
cmd.Parameters.Add(new OleDbParameter("@r", OleDbType.Boolean));
The Bool variable r gets it's value with the line
bool r = Repair_checkBox.Checked;
However changing the line gives me an error saying "Failed Due to Parameter r has no default value"
The only checkbox line before the r variable is don and the corresponding checkbox is ticked, which is why I think it doesn't error.
I am only learning C# so the database will never be used. Therefore I am concentrating on getting it working rather than security, Which to me would make it even harder to understand.
|
|
|
|
|
Member 13261084 wrote: cmd.Parameters.Add(new OleDbParameter("@r", OleDbType.Boolean)); That adds and creates a parameter, but doesn't assign a value for it yet. That's why it is complaining about the default value; it has no value assigned.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
How do I go about assigning a value to it? I tried doing "r= Repair_checkBox.Checked;" before and after the line and still get the same error.
|
|
|
|
|
Member 13261084 wrote: How do I go about assigning a value to it? Something like below should work;
OleDbParameter op = new OleDbParameter("@r", OleDbType.Boolean);
op.Value = Repair_checkBox.Checked;
cmd.Parameters.Add(op);
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Thanks for that but I get the same error.
However if I change the line
cmd.Parameters.Add(op); to
cmd.Parameters.Add(op.Value); I get the error message "Failed due to The OleDbParameterCollection only accepts non-null OleDbParameter type objects, not Boolean objects"
stepping through the code op.Value equals false yet it seems to be treating it as if it is blank.
|
|
|
|
|
Member 13261084 wrote: Thanks for that but I get the same error. Post the full exception. Is it pointing to the same line?
Member 13261084 wrote: I get the error message "Failed due to The OleDbParameterCollection only accepts non-null OleDbParameter type objects, not Boolean objects" Exactly as it says; you add a OleDbParameter object to cmd.Parameters. The .Value should be pointing to the boolean.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Hi I changed the code back to what you suggested.
I'm not sure how to post the full exception but the error happens when it tries to execute the query
cmd.ExecuteNonQuery();
as soon as it tries to execute this line it jumps to the catch statement which runs a messagebox that gives the exception message. I can do the exception.ToString and screen print it, but I cant find a way to upload the image on this site and it is quite large. However the exception code that I get is 0x80040E10 the rest of the text is, the line after the exception message talks about error handling, next line is talking about the Parameters and not being able to get a result, this is followed by a line talking about behavior followed by a line that talks about ExecuteReaderInternal at ExecuteNonQuery
The exception message that I get is "Parameter r has no default value"
however in the locals window it shows "r false bool"
|
|
|
|
|
Hi I have sorted it. The mistake was that deleted a field from the query yesterday when building it because I was having trouble with the where part of the statement. I didn't realise that I had to have that field in the query since I was calling the fields by name. Any way with that field put back in and your code, it is all working
|
|
|
|
|
Good to hear
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Hi,
0. Welcome to (C#) programming.
1. Your piecemeal reporting makes it very difficult to get an overall picture of what is going on, I had to copy each of your messages into a single file to understand and check it somewhat...
2. MessageBoxes aren't very good for debugging, I much prefer logging (to a file).
You can read about it here: Article: A simple logging scheme[^] .
When you write an Exception.ToString() result to a file, you can look at it at your leasure; and you can copy and paste all or parts of it here.
3. From Google "0x80040e10":
OleDbException (0x80040e10): No value given for one or more required parameters.
4. Some databases know about booleans, and allow them to have either two (true/false) or three (true/false/unknown) values. This is a probable cause for problems.
My guess: it would probably be very wise to tell your database what default value you want (either true or false, not unknown/null).
This may be sufficient for your code to start working (I mean without exception, not necessarily correctly).
5.
You are probably right that a boolean is the culprit, and your current attempt uses five boolean fields; fixing one won't help a bit. If something is wrong with one of them, the same probably applies to all of them. Hence my urgent advice:
- create a small table with only one number and one bool;
- use it to get successful INSERT and UPDATE operations, so you find out how to do that;
- only then attempt your complex table with real fields and data.
In general: try walking before running.
6. your subject line refers to the update query, however your messages seem to discuss inserts all the time??
[ADDED LATER]
7. IMO you need an explicit three-line approach, something like:
OleDbParameter parameter = new OleDbParameter("@r", OleDbType.Boolean);
parameter.Value = myCheckBox.Checked;
cmd.Parameters.Add(parameter);
Good luck,
modified 23-Jul-19 14:13pm.
|
|
|
|
|
I know partial classes were primarily introduced to facilitate code generation but I use them on those occasions when I have to include a lot of tightly coupled, but loosely feature related items to a class.
Like, for my Context Free Grammar class (always referred to as a CFG in compsci circles) i have
Cfg.cs
Cfg.Validation.cs
Cfg.Computation.cs
Cfg.Symbols.cs
etc.
each one being partial class Cfg
Am I crazy for doing this?
Normally I like to spread features across several different classes but sometimes it just doesn't make sense to do so. This is one of those cases.
I could use regions to accomplish some of the source segregation but I find partial classes make moving from section to section easier in devstudio
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
codewitch honey crisis wrote: Am I crazy for doing this? Not for this
I think whatever organizational scheme that works for you is great; using ReSharper makes moving a selection of whatever into a new partial Class a single menu action + selecting (via CheckBoxes) which items in the selection you want to move + optionally renaming the new partial Class.
Of course, you do end up with multiple files ... the presence of which are known to tempt demons.
cheers, Bill
«Where is the Life we have lost in living? Where is the wisdom we have lost in knowledge? Where is the knowledge we have lost in information?» T. S. Elliot
|
|
|
|
|
Oh I'm quite mad.
But yeah, this way of organizing has worked well for me since I started doing it.
The thing about the multiple files is I have a merge utility that integrates with VS that will package source code for me, so I can get it in one file if I want it.
I have a core source library that covers everything from MIDI to webserving to threading. It's just things I've built over the years that are useful and I use this tool to "export" bits of it in manageable chunks.
Maybe I should release that here sometime.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
codewitch honey crisis wrote: ... merge utility that integrates with VS that will package source code for me ... a core source library that covers everything from MIDI to webserving to threading. ... I use this tool to "export" bits of it in manageable chunks.
Maybe I should release that here sometime. Good idea !
«Where is the Life we have lost in living? Where is the wisdom we have lost in knowledge? Where is the knowledge we have lost in information?» T. S. Elliot
|
|
|
|
|
I've held off on it mostly because it goes against MS coding "best practices" but they seem to think everything should be its own DLL/assembly.
I don't operate that way. I like my smaller apps to be as self-contained and as simply packaged as possible so I jump through hoops to make it the way i like it.
I tested the waters here with the idea and it seemed like the tide was against me on this.
So if i publish i expect wars over it to ensue.
hah. maybe more reason to do it.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
I think Microsoft's built in object templates (especially the new class template) should default to public partial , because that's what is used most.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
That question is not as easy as it looks like.
Normally, a class should care about one (and exactly only one) thing.
But still, there may be some aspects differing from the actual purpose of the class.
I use partial classes typically for the purposes of configuration (checking that the configuration is consistent, and that all mandatory dependencies were injected) and another partial class for test accessors (i.e. special functions for setting up that class with a specific state for test purposes, accessing non-public members as reporters for test purposes etc.).
Oh sanctissimi Wilhelmus, Theodorus, et Fredericus!
|
|
|
|
|
I generally like to keep classes tightly factored like that as well, but sometimes, particularly with non-trivial engine style things, you're going to probably have something that's got a lot of tightly coupled functionality that is nevertheless loosely related and your choices are to break encapsulation, greatly expand the surface area of your interconnected class APIs or encase the functionality all in one class. The latter leads to a much smaller test matrix in cases where it's appropriate.
There's a time and a place for breaking just about every rule of thumb. =)
But that being said, I take your point. In most circumstances we wouldn't disagree, and I'm not sure we would in these cases either.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|