|
The error you are getting indicates that Parameters are being added more that once so your loop is being executed multiple times.
Add the parameters when creating the SqlCommand
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "update VopMessage_tbl set MarkedNumber=@MarkedNumber where Byte24=@Byte24 and Byte4=@Byte4";
cmd.Connection = con;
cmd.Parameters.Add("@Byte24", ...);
cmd.Parameters.Add("@Byte4", ...);
cmd.Parameters.Add("@MarkedNumber", ...);
Then inside the loop update the values each time
cmd.Parameters["@Byte24"] = vms.Byte24;
cmd.Parameters["@Byte4"] = vms.Byte4;
string All2BytesOfTwoMarkedNumber = mNumber.Byte4 + mNumber.Byte5;
cmd.Parameters["@MarkedNumber"] = All2BytesOfTwoMarkedNumber;
cmd.ExecuteNonQuery();
You should also make use of the using statement
using(SqlCommand cmd = new SqlCommand("update VopMessage_tbl set MarkedNumber=@MarkedNumber where Byte24=@Byte24 and Byte4=@Byte4", conn)
{
}
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Thanks very Much ...It Work Correctly.
|
|
|
|
|
What error message are you getting?
Jack of all trades ~ Master of none.
|
|
|
|
|
You could easily find the error if you just used the tools that come with Visual Studio - namely, the debugger.
".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 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
Hi
I have discovered an issue using Type.GetProperties on a COM object when running under .NET 3.5 & .NET 4.0.
The following code uses the Microsoft Scripting Runtime COM object as an example - it has the same behaviour with any COM object I have tried. Under .NET 3.5, it correctly returns an array containing one property (the Drives property). Under .NET 4.0, it returns no properties.
Scripting.FileSystemObject fs = new Scripting.FileSystemObject();
Type t = fs.GetType();
PropertyInfo[] props = t.GetProperties();
Type.GetProperties seems to work correctly on .NET objects and only seems a problem with COM objects.
I have some generic code that sets property values by using a string variable as the name that works in .NET 3.5 and now fails in .NET 4.0.
I know that I can upgrade the code to use the dynamic type in .NET 4.0 to do this BUT why is this not backwards compatible or at least documented in some way that is easy to find?
Kind regards
Andy
|
|
|
|
|
Sorry to state the obvious, but since Microsoft are the providers of this software, I believe they are best qualified to answer your question.
I must get a clever new signature for 2011.
|
|
|
|
|
Sorry but that part of the posting with a question mark was really a rhetorical question and I could not report it to MS as the forums appeared to be down when I tried. I was hoping that someone may have experienced the same issue and had some constructive advice.
My comment that I could always use the new dynamic type seems wide of the mark and it doesn't help me at all. For the purposes of the project I'm working on, I need to be able to call a property by its name since I am mapping some data between two applications and the mapping details are stored in XML configuration files.
I need to use .NET 4.0 since I am developing an application to be certified for Dynamics CRM 5 and this looks like it will only allow .NET 4.0. The other application is a legacy application that only has a COM interface so I'm a little stuck at the moment.
Regards
Andy
|
|
|
|
|
This is the example they give on the MSDN site:
PropertyInfo[] myPropertyInfo;
myPropertyInfo = Type.GetType("System.Type").GetProperties();
Slightly different from yous, but I'd give it a try.
".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 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
Hi John,
I think you will find that
string x = "";<br />
x.GetType().GetProperties()
is exactly the same as
Type.GetType("System.String").GetProperties()
Thanks for taking the time to answer though
Regards
Andy
|
|
|
|
|
Yeah, I know, but stranger things have happened in .Net.
".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 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
Is there a way to still sort the Class View by type (without grouping by type) and have the enums that are defined within a class only display within that class like members do?
|
|
|
|
|
i want to copy a tex from texbox and paste it another one in my form
i copy it with that code
Clipboard.SetText(textBox1.SelectedText);
and paste it with that
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if ((e.Modifiers == Keys.Control)&&(e.KeyCode == Keys.V))
textBox2.Text = Clipboard.GetText();
}
but the problem is it pastes selceted text two times but when i try like that
(e.Modifiers == Keys.Control)
it pastes one time
what should i do now ?
vemedya.com
|
|
|
|
|
I've tested your code and it is working fine for me. I think that the problem must be somewhere else. What is the content of the Clipboard when pasting?
|
|
|
|
|
its content is te selected text from the textbox..for example if i write 'w' in my textbox and paste it to my another box it appears 'ww'
vemedya.com
|
|
|
|
|
hey friend thanks for reply..i solved my problem ..i set my form's KeyPreview false and it works now..
vemedya.com
|
|
|
|
|
Glad to help - at least your code is correct. All I could do is tell you that the problem must be somewhere else
|
|
|
|
|
CTRL/V is handled automatically by some Controls.
You make the Form react to it, but didn't tell the system that is all you want to happen, so if a suitable Control has focus, it will still oblige the CTRL/V.
Clearing KeyPreview is unlikely the solution; it was set for a reason. Look for KeyEventArgs.Handled and SuppressKeyPress.
|
|
|
|
|
I believe you want to handle an event for the control you're pasting into as opposed to handling it in the form.
".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 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
i have 17 textboxes on my form and i want the user can copy from one box and paste to another...that is why i did so
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if ((e.Modifiers == Keys.Control) && (e.KeyCode == Keys.V))
{
foreach (Control item in this.Controls)
{
if (item.GetType().Name == "TextBox")
if (item.Enabled)
item.Text = Clipboard.GetText();
}
}
}
it works well..but after i saw your replies i wonder if there is better way or i am in wrong way ?
vemedya.com
|
|
|
|
|
I found this on google (search phrase is "c# textbox events"):
http://www.vcskicks.com/clipboard-textbox.php[^]
".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 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
You shoulnd't have to do anything at all. The TextBox already supports Copy/Paste on its own without any code from you.
|
|
|
|
|
Hello,
I would like to extract the text with coordinates on pdf file.
Thank you verry mutch.
|
|
|
|
|
That's nice. What have you tried? What do you think your first step in the process would be.
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
Hello,
Is there a way to extract the text on a specific area (with coordinates)?
Thank you verry mutch.
|
|
|
|
|